Skip to content

CD

CD #11

Workflow file for this run

name: CD
on:
push:
tags: "v*"
# allow manually triggering this workflow
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into Docker Hub
uses: docker/login-action@v3
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
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
- 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}}