File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 22name : Publish container image
33on :
44 push :
5- pull_request :
65concurrency :
76 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
87 cancel-in-progress : true
8+ env :
9+ BRANCH : ${{ github.head_ref || github.ref_name }}
910jobs :
1011 push_to_registry :
1112 name : Push container image to GitHub Container Registry
2122 registry : ghcr.io
2223 username : ${{ github.actor }}
2324 password : ${{ secrets.GITHUB_TOKEN }}
25+ - name : Generate tag name
26+ run : |
27+ if [[ ${BRANCH} == "main" ]]; then
28+ IMAGE_TAG="latest"
29+ else
30+ IMAGE_TAG="${BRANCH/\//-}"
31+ fi
32+ echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
2433 - name : Build and push container image
2534 uses : docker/build-push-action@v6
2635 with :
2736 push : true
28- tags : ghcr.io/${{ github.repository }}:latest
37+ tags : ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
You can’t perform that action at this time.
0 commit comments