Skip to content

Commit a93fce7

Browse files
committed
Tag images correctly
Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent ff1c18c commit a93fce7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/workflows/publish-image.yaml

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
name: Publish container image
33
on:
44
push:
5-
pull_request:
65
concurrency:
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 }}
910
jobs:
1011
push_to_registry:
1112
name: Push container image to GitHub Container Registry
@@ -21,8 +22,16 @@ jobs:
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 }}

0 commit comments

Comments
 (0)