Skip to content

Commit 9cedeab

Browse files
committed
ci: update Docker tagging logic
1 parent 3d4c14c commit 9cedeab

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

.github/workflows/nodejs.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ jobs:
2121
username: ${{ secrets.DOCKER_USERNAME }}
2222
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
2323

24+
- name: Generate tag name
25+
id: prep
26+
run: |
27+
DOCKER_IMAGE=johanbook/file-domain-server
28+
VERSION=latest
29+
SHORTREF=${GITHUB_SHA::8}
30+
31+
# If this is git tag, use the tag name as a docker tag
32+
if [[ $GITHUB_REF == refs/tags/* ]]; then
33+
VERSION=${GITHUB_REF#refs/tags/v}
34+
fi
35+
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}"
36+
37+
# If the VERSION looks like a version number, assume that
38+
# this is the most recent version of the image and also
39+
# tag it 'latest'.
40+
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
41+
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
42+
fi
43+
44+
# Set output parameters.
45+
echo ::set-output name=tags::${TAGS}
46+
echo ::set-output name=docker_image::${DOCKER_IMAGE}
47+
2448
- name: Build Docker images
2549
uses: docker/build-push-action@v2
2650
with:
@@ -29,4 +53,4 @@ jobs:
2953
file: ./Dockerfile
3054
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le
3155
push: true
32-
tags: johanbook/file-domain-server:${{GITHUB_REF#refs/tags/v}}
56+
tags: ${{ steps.prep.outputs.tags }}

0 commit comments

Comments
 (0)