chore(version): v0.1.3 #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push image to docker hub | |
on: | |
push: | |
tags: | |
- v[0-9]+.[0-9]+.[0-9]+ | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Determine Docker image tag when event is 'push' | |
if: ${{ github.event_name == 'push' }} | |
shell: bash | |
# Docker tag will be the tag that triggered the workflow run | |
run: echo "DOCKER_TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV | |
- name: Determine Docker image tag when event is 'workflow_dispatch' | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
shell: bash | |
# Docker tag will be the latest commit hash of the branch that triggered the workflow run | |
run: | | |
if [[ ${{ github.ref_type }} == 'tag' ]]; then | |
DOCKER_TAG=$GITHUB_REF_NAME | |
else | |
DOCKER_TAG=$(git rev-parse --short=7 "$GITHUB_REF_NAME^{commit}") | |
fi | |
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push Docker images tagged with both latest and above determined tag | |
uses: docker/build-push-action@v5 | |
# If the workflow trigger event is `push`, then its clear that a new tag has been pushed, hence we push images tagged with latest as well | |
if: ${{ github.event_name == 'push' }} | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: juspaydotin/hyperswitch-card-vault:latest,juspaydotin/hyperswitch-card-vault:${{ env.DOCKER_TAG }} | |
- name: Build and push Docker image tagged only with above determined tag | |
uses: docker/build-push-action@v5 | |
# If the workflow is triggered manually, the built image need not necessarily be latest | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: juspaydotin/hyperswitch-card-vault:${{ env.DOCKER_TAG }} |