From a32df56f9925dae139620eda67e59c8978889c3b Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 16 Jul 2021 17:35:36 -0500 Subject: [PATCH] Skip Docker if already pushed --- ci/steps/push-docker-manifest.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ci/steps/push-docker-manifest.sh b/ci/steps/push-docker-manifest.sh index 62ac0317..e866e606 100755 --- a/ci/steps/push-docker-manifest.sh +++ b/ci/steps/push-docker-manifest.sh @@ -1,6 +1,17 @@ #!/usr/bin/env bash set -euo pipefail +# See if this version already exists on Docker Hub. +function version_exists() { + local output + output=$(curl --silent "https://index.docker.io/v1/repositories/codercom/code-server/tags/$VERSION") + if [[ $output == "Tag not found" ]]; then + return 1 + else + return 0 + fi +} + # Import and push the Docker image for the provided arch. push() { local arch=$1 @@ -26,6 +37,11 @@ main() { cd "$(dirname "$0")/../.." source ./ci/lib.sh + if version_exists; then + echo "$VERSION is already pushed" + return + fi + download_artifact release-images ./release-images if [[ ${CI-} ]]; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin