Skip Docker if already pushed

This commit is contained in:
Asher 2021-07-16 17:35:36 -05:00
parent 4cfa384bb4
commit a32df56f99
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 16 additions and 0 deletions

View File

@ -1,6 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail 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. # Import and push the Docker image for the provided arch.
push() { push() {
local arch=$1 local arch=$1
@ -26,6 +37,11 @@ main() {
cd "$(dirname "$0")/../.." cd "$(dirname "$0")/../.."
source ./ci/lib.sh source ./ci/lib.sh
if version_exists; then
echo "$VERSION is already pushed"
return
fi
download_artifact release-images ./release-images download_artifact release-images ./release-images
if [[ ${CI-} ]]; then if [[ ${CI-} ]]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin