Skip to content

Commit

Permalink
fix: use single method to get docker tag in CD pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-ahuja committed Feb 18, 2024
1 parent e4d8558 commit ba0b369
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,16 @@ jobs:
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: dhruvahuja/backend_burger
tags:
# use git tag pattern
type=semver,pattern={{version}}

- name: Debug Tag
run: echo "TAG = ${{steps.meta.outputs.tags}}"

- name: 'Get Latest tag'
id: latestTag
id: latest-tag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.1

- name: Determine Tag
id: determine_tag
run: if [[ -z "${{ steps.meta.outputs.tags }}" ]]; then
echo "::set-output name=tag::${{ steps.latestTag.outputs.tag }}"; else
echo "::set-output name=tag::${{ steps.meta.outputs.tags }}"; fi
shell: bash
fallback: latest

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: dhruvahuja/backend_burger:${{ steps.determine_tag.outputs.tag }}
labels: ${{steps.meta.outputs.labels}}
tags: dhruvahuja/backend_burger:${{ steps.latest-tag.outputs.tag }}
labels: ${{steps.latest-tag.outputs.tag}}

0 comments on commit ba0b369

Please sign in to comment.