Commit a93fce7 1 parent ff1c18c commit a93fce7 Copy full SHA for a93fce7
File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 2
2
name : Publish container image
3
3
on :
4
4
push :
5
- pull_request :
6
5
concurrency :
7
6
group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
8
7
cancel-in-progress : true
8
+ env :
9
+ BRANCH : ${{ github.head_ref || github.ref_name }}
9
10
jobs :
10
11
push_to_registry :
11
12
name : Push container image to GitHub Container Registry
21
22
registry : ghcr.io
22
23
username : ${{ github.actor }}
23
24
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
24
33
- name : Build and push container image
25
34
uses : docker/build-push-action@v6
26
35
with :
27
36
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