Skip to content
This repository was archived by the owner on Jul 5, 2021. It is now read-only.

Commit 9be0a66

Browse files
1azizAziz
andauthored
add condition to add latest tag for images (#148)
Co-authored-by: Aziz <aziz@cs>
1 parent 9a97e49 commit 9be0a66

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,29 @@ jobs:
5656
- name: Prepare
5757
id: prep
5858
run: |
59+
IS_LATEST=false
5960
IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
6061
DOCKER_IMAGE=ghcr.io/${IMAGE_REPOSITORY}
61-
6262
VERSION=edge
63+
6364
if [[ $GITHUB_REF == refs/tags/* ]]; then
6465
VERSION=${GITHUB_REF#refs/tags/}
66+
IS_LATEST=true
6567
elif [[ $GITHUB_REF == refs/heads/* ]]; then
6668
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
69+
if [[ $GITHUB_REF == refs/heads/master ]]; then
70+
IS_LATEST=true
71+
fi
6772
elif [[ $GITHUB_REF == refs/pull/* ]]; then
6873
VERSION=pr-${{ github.event.number }}
6974
fi
7075
7176
TAGS="${DOCKER_IMAGE}:${VERSION}"
77+
78+
if [ "$IS_LATEST" = true ] ; then
79+
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
80+
fi
81+
7282
if [ "${{ github.event_name }}" = "push" ]; then
7383
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
7484
fi

0 commit comments

Comments
 (0)