From 7e647e50c583ec1d3dd2201e65b28f39aed958f7 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Tue, 23 Aug 2022 16:05:48 -0700 Subject: [PATCH] Check all tags before pushing This check was placed incorrectly in 7d4daa92af7269240a349bca5c56589f27563bee. Two tags can point to the same image and if one of them is pushed first, the other will error even though both were "new" at the start of the script. --- devel/push | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devel/push b/devel/push index 48fa4d2c..9facf42a 100755 --- a/devel/push +++ b/devel/push @@ -5,7 +5,7 @@ # By default this publishes the "latest" tag, but you can provide other tags in # addition to or instead of "latest". # -# Errors if a tagged image has already been pushed. +# Errors if any of the tagged images have already been pushed. # set -euo pipefail @@ -18,12 +18,13 @@ BASE_IMAGE="nextstrain/base" BASE_BUILDER_IMAGE="nextstrain/base-builder" for tag in "$@"; do - if [[ $(docker image inspect --format "{{.RepoDigests}}" $BASE_IMAGE:$tag) != '[]' || $(docker image inspect --format "{{.RepoDigests}}" $BASE_BUILDER_IMAGE:$tag) != '[]' ]]; then - echo "At least one of the tagged images has already been pushed. This can happen if the newly built image is not available in the local registry." >&2 + echo "At least one of $BASE_IMAGE:$tag and $BASE_BUILDER_IMAGE:$tag has already been pushed. This can happen if the newly built image is not available in the local registry." >&2 exit 1 fi +done +for tag in "$@"; do docker push $BASE_BUILDER_IMAGE:$tag docker push $BASE_IMAGE:$tag done