Skip to content

Commit

Permalink
added back script which is in use
Browse files Browse the repository at this point in the history
  • Loading branch information
a-thaler committed Dec 16, 2024
1 parent df9f131 commit 0a21424
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions hack/await_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# standard bash error handling
set -o nounset # treat unset variables as an error and exit immediately.
set -o errexit # exit immediately when a command fails.
set -E # must be set if you want the ERR trap
set -o pipefail # prevents errors in a pipeline from being masked

# Expected variables:
# IMAGE_REPO - binary image repository
# GITHUB_TOKEN - github token
# TRIGGER - event which triggered the workflow, for PRs it is the commit SHA, for push events it is the GITHUB_REF
# QUERY_INTERVAL - time to wait between queries in seconds

PROTOCOL=docker://

# timeout after 15 minutes
TIMEOUT=900
START_TIME=$SECONDS

until $(skopeo list-tags ${PROTOCOL}${IMAGE_REPO} | jq '.Tags|any(. == env.TRIGGER)'); do
if (( SECONDS - START_TIME > TIMEOUT )); then
echo "Timeout reached: ${IMAGE_REPO}:${TRIGGER} not found within $(( TIMEOUT/60 )) minutes"
exit 1
fi
echo "Waiting for binary image: ${IMAGE_REPO}:${TRIGGER}"
echo "Trigger: $TRIGGER"
sleep "$QUERY_INTERVAL"
done

echo "Binary image: ${IMAGE_REPO}:${TRIGGER} available"

0 comments on commit 0a21424

Please sign in to comment.