aboutsummaryrefslogtreecommitdiffstats
path: root/screwdriver/release-container-image.sh
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@yahooinc.com>2022-02-16 11:45:37 +0100
committerArnstein Ressem <aressem@yahooinc.com>2022-02-16 11:45:37 +0100
commitfcf3331e3c24b809a5c9d8043a86e3b6812a41cd (patch)
tree73b1c266dedd1facbd11645c9cb09ac3e1a7da8b /screwdriver/release-container-image.sh
parent90694216f0c1cd2dcb43fa346051949c72a9a438 (diff)
Make sure that we publish to both docker.io and ghcr.io.
Diffstat (limited to 'screwdriver/release-container-image.sh')
-rwxr-xr-xscrewdriver/release-container-image.sh30
1 files changed, 19 insertions, 11 deletions
diff --git a/screwdriver/release-container-image.sh b/screwdriver/release-container-image.sh
index 4d2bbf8a4ec..87f06762169 100755
--- a/screwdriver/release-container-image.sh
+++ b/screwdriver/release-container-image.sh
@@ -10,11 +10,6 @@ fi
readonly VESPA_VERSION=$1
-if curl -fsSL https://index.docker.io/v1/repositories/vespaengine/vespa/tags/$VESPA_VERSION &> /dev/null; then
- echo "Container image docker.io/vespaengine/vespa:$VESPA_VERSION aldready exists."
- exit 0
-fi
-
if [[ -z "$DOCKER_HUB_DEPLOY_KEY" ]]; then
echo "Environment variable DOCKER_HUB_DEPLOY_KEY must be set, but is empty."
exit 1
@@ -31,14 +26,27 @@ cd $BUILD_DIR
git clone --depth 1 https://github.com/vespa-engine/docker-image
cd docker-image
-docker build --build-arg VESPA_VERSION=$VESPA_VERSION --tag docker.io/vespaengine/vespa:$VESPA_VERSION --tag docker.io/vespaengine/vespa:latest .
+docker build --build-arg VESPA_VERSION=$VESPA_VERSION \
+ --tag docker.io/vespaengine/vespa:$VESPA_VERSION --tag docker.io/vespaengine/vespa:latest \
+ --tag ghcr.io/vespa-engine/vespa:$VESPA_VERSION --tag ghcr.io/vespa-engine/vespa:latest .
# Push to Docker Hub
docker login --username aressem --password "$DOCKER_HUB_DEPLOY_KEY"
-docker push docker.io/vespaengine/vespa:$VESPA_VERSION
-docker push docker.io/vespaengine/vespa:latest
+if curl -fsSL https://index.docker.io/v1/repositories/vespaengine/vespa/tags/$VESPA_VERSION &> /dev/null; then
+ echo "Container image docker.io/vespaengine/vespa:$VESPA_VERSION aldready exists."
+else
+ docker push docker.io/vespaengine/vespa:$VESPA_VERSION
+ docker push docker.io/vespaengine/vespa:latest
+fi
# Push to GitHub Container Registry
-docker login --username aressem --password "$DOCKER_HUB_DEPLOY_KEY" ghcr.io
-docker push ghcr.io/vespa-engine/vespa:$VESPA_VERSION
-docker push ghcr.io/vespa-engine/vespa:latest
+docker login --username aressem --password "$GHCR_DEPLOY_KEY" ghcr.io
+JWT=$(curl -sSL -u aressem:$GHCR_DEPLOY_KEY "https://ghcr.io/token?service=ghcr.io&scope=repository:vespa-engine/vespa:pull" | jq -re '.token')
+IMAGE_TAGS=$(curl -sSL -H "Authorization: Bearer $JWT" https://ghcr.io/v2/vespa-engine/vespa/tags/list | jq -re '.tags[]')
+if grep $VESPA_VERSION <<< "$IMAGE_TAGS" &> /dev/null; then
+ echo "Container image ghcr.io/vespa-engine/vespa:$VESPA_VERSION aldready exists."
+else
+ docker push ghcr.io/vespa-engine/vespa:$VESPA_VERSION
+ docker push ghcr.io/vespa-engine/vespa:latest
+fi
+