File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,17 +47,10 @@ jobs:
4747 - name : Define build variables
4848 id : vars
4949 run : |
50- # Get the commit SHA
5150 if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
5251 COMMIT_SHA="${{ github.event.workflow_run.head_sha }}"
53- else
54- COMMIT_SHA="${{ github.sha }}"
55- fi
56-
57- # Determine image tag
58- if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
59- # Find the tag pointing at this commit
60- TAG_NAME=$(git tag --points-at $COMMIT_SHA)
52+ # Get tag name pointing to this SHA from remote
53+ TAG_NAME=$(git ls-remote --tags origin | grep $COMMIT_SHA | grep -o 'refs/tags/v.*' | sed 's#refs/tags/##' | head -n1)
6154 if [[ -n "$TAG_NAME" ]]; then
6255 IMAGE_TAG="$TAG_NAME"
6356 IMAGE_TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$IMAGE_TAG,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
@@ -67,10 +60,10 @@ jobs:
6760 fi
6861 else
6962 # develop branch - use commit SHA only
70- IMAGE_TAG="$COMMIT_SHA "
63+ IMAGE_TAG="${GITHUB_SHA} "
7164 IMAGE_TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$IMAGE_TAG"
7265 fi
73-
66+
7467 echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
7568 echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
7669 echo "image_tags=$IMAGE_TAGS" >> $GITHUB_OUTPUT
You can’t perform that action at this time.
0 commit comments