Skip to content

Commit 0c6ef59

Browse files
committed
use branch name for image tag, latest for main branch
1 parent ae9a6af commit 0c6ef59

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/publish-image.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ jobs:
2222
- uses: actions/checkout@v3
2323

2424
# https://github.community/t/github-actions-repository-name-must-be-lowercase/184924
25-
- name: downcase REPO
25+
- name: downcase REPO & set branch/image tag name
2626
run: |
2727
echo "REPO_LC=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
28+
export "BRANCH=${GITHUB_REF##*/}"
29+
if [ $BRANCH == "main" ] || [ $BRANCH == "master" ]; then
30+
echo "TAG=latest" >> ${GITHUB_ENV};
31+
else
32+
echo "TAG=${BRANCH}" >> ${GITHUB_ENV};
33+
fi
34+
2835
# https://github.com/marketplace/actions/push-to-ghcr
2936
- name: Build and publish a Docker image for ${{ github.repository }}
3037
uses: macbre/push-to-ghcr@master
3138
with:
3239
image_name: ${REPO_LC}-backend
3340
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
tags: ${TAG}
3442
# optionally push to the Docker Hub (docker.io)
3543
# docker_io_token: ${{ secrets.DOCKER_IO_ACCESS_TOKEN }} # see https://hub.docker.com/settings/security

0 commit comments

Comments
 (0)