Skip to content

Commit

Permalink
ci(workflow): fixed use of docker tag
Browse files Browse the repository at this point in the history
  • Loading branch information
arhamj committed Oct 25, 2024
1 parent 24de945 commit cd8cb3e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ on:
inputs:
tag:
description: 'Tag for the Docker image'
required: false
default: 'latest' # Default tag if none is provided
required: true

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -48,14 +47,22 @@ jobs:
else
echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV # Actual branch name for push events
fi
- name: Set Docker image tag
id: set-docker-tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "DOCKER_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ env.BRANCH_NAME }}-${{ env.SHORT_COMMIT_HASH }}" >> $GITHUB_ENV
fi
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.SHORT_COMMIT_HASH }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}::${{ env.DOCKER_TAG }}
labels: |
version=${{ env.SHORT_COMMIT_HASH }}
branch=${{ env.BRANCH_NAME }}
Expand Down

0 comments on commit cd8cb3e

Please sign in to comment.