Skip to content

Commit

Permalink
add wait for image step
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanxin committed Sep 4, 2024
1 parent 466710c commit 045ee95
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: "Create release"

env:
IMAGE_REPO: europe-docker.pkg.dev/kyma-project/prod/template-operator
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions scripts/release/wait_for_image.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 045ee95

Please sign in to comment.