From 2d814a787c778079cdc7573e8c41954e9a3bbe1c Mon Sep 17 00:00:00 2001 From: Friedrich Wilken Date: Tue, 12 Dec 2023 19:37:35 +0100 Subject: [PATCH] Check if the release image was created. --- .github/workflows/create-release.yaml | 3 +++ scripts/image_exists.sh | 30 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 scripts/image_exists.sh diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 764a45b5..b278215a 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -59,6 +59,9 @@ jobs: git tag ${{ github.event.inputs.name }} git push origin ${{ github.event.inputs.name }} + - name: Check if image was build + run: | + outputs: release_id: ${{ steps.create-draft.outputs.release_id }} diff --git a/scripts/image_exists.sh b/scripts/image_exists.sh new file mode 100755 index 00000000..a06469ac --- /dev/null +++ b/scripts/image_exists.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +TIMEOUT=${1:-600} +INTERVAL=${2:-20} +TAG=${3:-latest} +IMAGE=${4:-europe-docker.pkg.dev/kyma-project/prod/nats-manager} + +start_time=$(date +%s) +end_time=$((start_time + TIMEOUT)) + +while true; do + docker manifest inspect $IMAGE:$TAG + # Check the exit status + if [ $? -eq 0 ]; then + echo "Image found." + exit 0 + else + echo "Image not found, yet." + fi + + current_time=$(date +%s) + + # Check if the TIMEOUT has been reached + if [ $current_time -ge $end_time ]; then + echo "TIMEOUT reached. Image was not found in time." + exit 1 + fi + + sleep $INTERVAL +done