diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index a6b3d26..274292e 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -1,5 +1,7 @@ name: "Create release" +env: + IMAGE_REPO: europe-docker.pkg.dev/kyma-project/prod/template-operator on: workflow_dispatch: inputs: @@ -51,7 +53,13 @@ jobs: - name: Create lightweight tag run: | git tag ${{ github.event.inputs.name }} - git push origin ${{ github.event.inputs.name }} + git push origin ${{ github.event.inputs.name }} --tags + - name: Wait for the Docker image + timeout-minutes: 20 + env: + ITERATIONS: 40 + SLEEP_SECONDS: 30 + run: ./scripts/release/wait_for_image.sh ${{ env.IMAGE_REPO }}:${{ github.event.inputs.name }} $ITERATIONS $SLEEP_SECONDS - name: Create release assets id: create-assets env: diff --git a/scripts/release/wait_for_image.sh b/scripts/release/wait_for_image.sh new file mode 100755 index 0000000..08de10b --- /dev/null +++ b/scripts/release/wait_for_image.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -o nounset +set -o errexit +set -E +set -o pipefail + +DOCKER_IMAGE=$1 +ITERATIONS=${2:-30} +SLEEP_TIME="${3:-30}" + +for (( c=1; c<=ITERATIONS; c++ )) +do + if docker manifest inspect "$DOCKER_IMAGE" > /dev/null 2>&1; then + exit 0 + fi + echo "Attempt $c: Docker image: $DOCKER_IMAGE doesn't exist" + if [[ $c -lt $ITERATIONS ]]; then + sleep "$SLEEP_TIME" + fi +done + +echo "Fail: Docker image: $DOCKER_IMAGE doesn't exist" +exit 1