From a8457e96bfb3490a3146b2256ea1e671ce595737 Mon Sep 17 00:00:00 2001 From: Bill Church Date: Sat, 30 Jul 2022 19:32:31 +0000 Subject: [PATCH] chore: update workflow --- .github/workflows/docker-multiplatform.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-multiplatform.yml b/.github/workflows/docker-multiplatform.yml index 11de129..789c28a 100644 --- a/.github/workflows/docker-multiplatform.yml +++ b/.github/workflows/docker-multiplatform.yml @@ -20,21 +20,27 @@ jobs: id: prep run: | DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} - VERSION=main + # If this is git tag, use the tag name as a docker tag if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} + TAGS="${DOCKER_IMAGE}:${VERSION}" + fi + + # If this is git branch, use the branch name as a docker tag + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/heads/} + TAGS="${DOCKER_IMAGE}:${VERSION}" fi - TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}" # If the VERSION looks like a version number, assume that # this is the most recent version of the image and also - # tag it 'latest'. + # tag it 'latest'. This is done by just specifying the ${DOCKER_IMAGE} + # without a tag. if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - TAGS="$TAGS,${DOCKER_IMAGE}:latest" + TAGS="$TAGS,${DOCKER_IMAGE}" fi - # Set output parameters. echo ::set-output name=tags::${TAGS} echo ::set-output name=docker_image::${DOCKER_IMAGE}