From c6b9d3e4971a966d8fd1dcb54c37954bea744b2d Mon Sep 17 00:00:00 2001 From: maany Date: Thu, 16 Feb 2023 13:53:43 +0100 Subject: [PATCH] build: allow builds of latest custom_tags together if the build context contains 'push-latest' and 'custom-tag=something' in the spec, then image_tag- and latest_tag- will both be pushed to DockerHub. For example, 'fts-cron/Dockerfile_java, push-tagged, push-latest, custom-tag=java' will push rucio/fts-cron:1.31.0-java, rucio/fts-cron:latest-java --- .github/workflows/docker-auto-build.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-auto-build.yml b/.github/workflows/docker-auto-build.yml index b341a68..5d5d269 100644 --- a/.github/workflows/docker-auto-build.yml +++ b/.github/workflows/docker-auto-build.yml @@ -23,7 +23,7 @@ jobs: 'probes, push-tagged, push-latest', 'fts, push-tagged, push-latest', 'fts-cron/Dockerfile_cpp, push-tagged, push-latest', - 'fts-cron/Dockerfile_java, push-tagged, push-latest, custom-tag=-java', + 'fts-cron/Dockerfile_java, push-tagged, push-latest, custom-tag=java', 'ssh, push-tagged, push-latest', 'xrootd, push-tagged, push-latest', 'xrootd-noauth, push-tagged, push-latest', @@ -93,6 +93,7 @@ jobs: # force-latest: if present, the latest tag will be force pushed to Docker Hub # latest-only: if present, only the latest tag will be pushed to Docker Hub # custom-tag=value: If present, the value of the custom tag will be appended to the image tag. + # If push-latest is also present, then the custom tag will be appended to the latest tag as well. # For example, custom-tag=java will append `java` to the image name. # # The following truth table is used to determine the Docker Hub tag @@ -182,13 +183,20 @@ jobs: if [[ $CONTEXT =~ custom-tag=([-a-zA-Z0-9]*) ]]; then CUSTOM_TAG="${BASH_REMATCH[1]}" if [[ -z $IMAGE_TAG ]]; then - IMAGE_TAG="${BASE_TAG}:${CUSTOM_TAG}" + IMAGE_TAG="${BASE_TAG}:${CUSTOM_TAG}" else - IMAGE_TAG="${IMAGE_TAG}${CUSTOM_TAG}" + IMAGE_TAG="${IMAGE_TAG}-${CUSTOM_TAG}" + fi + + if [[ -z $LATEST_TAG ]]; then + LATEST_TAG="${BASE_TAG}:latest-${CUSTOM_TAG}" + else + LATEST_TAG="${LATEST_TAG}-${CUSTOM_TAG}" fi else - echo "No custom tag detected!" + echo "No custom tag detected!" fi + echo $CONTEXT if [[ -z "$IMAGE_TAG" && -z "$LATEST_TAG" ]]; then