File tree Expand file tree Collapse file tree 2 files changed +28
-12
lines changed
Expand file tree Collapse file tree 2 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,26 @@ jobs:
109109 run : |
110110 set -eou pipefail
111111
112+ # Retry function with exponential backoff for rate limiting
113+ retry_with_backoff() {
114+ local max_attempts=5
115+ local attempt=1
116+ local delay=15
117+ while true; do
118+ if "$@"; then
119+ return 0
120+ fi
121+ if [ $attempt -ge $max_attempts ]; then
122+ echo "Command failed after $max_attempts attempts"
123+ return 1
124+ fi
125+ echo "Attempt $attempt failed, retrying in ${delay}s..."
126+ sleep $delay
127+ attempt=$((attempt + 1))
128+ delay=$((delay * 2))
129+ done
130+ }
131+
112132 REPOS=(
113133 "${{ inputs.repository }}"
114134 "ghcr.io/islandora-devops"
@@ -131,7 +151,7 @@ jobs:
131151 FIRST_TAG=$(echo "${{ inputs.tags }}" | awk '{print $1}')
132152 BASE_IMAGE_REF="${{ inputs.repository }}/${{ inputs.image }}:${FIRST_TAG}"
133153
134- docker buildx imagetools create \
154+ retry_with_backoff docker buildx imagetools create \
135155 ${TAG_ARGS} \
136156 "${BASE_IMAGE_REF}-amd64" \
137157 "${BASE_IMAGE_REF}-arm64"
Original file line number Diff line number Diff line change @@ -36,7 +36,6 @@ DOCKER_IMAGES=(
3636 homarus
3737 houdini
3838 hypercube
39- imagemagick
4039 java
4140 mariadb
4241 milliner
@@ -96,14 +95,17 @@ get_workflow_file() {
9695 fi
9796}
9897
99- # Check if a Docker image exists
98+ # Check if a Docker image exists using Docker Hub API
10099image_exists () {
101100 local image=" $1 "
102101 local tag=" $2 "
103- local full_image= " ${DOCKER_REPOSITORY} /${image} : ${tag} "
102+ local api_url= " https://hub.docker.com/v2/repositories/ ${DOCKER_REPOSITORY} /${image} /tags/ ${tag} "
104103
105- # Use docker manifest inspect to check if image exists (doesn't pull the image)
106- if docker manifest inspect " $full_image " & > /dev/null; then
104+ # Use Docker Hub API to check if tag exists (more reliable than docker manifest inspect)
105+ local http_code
106+ http_code=$( curl -s -o /dev/null -w " %{http_code}" " $api_url " )
107+
108+ if [[ " $http_code " == " 200" ]]; then
107109 return 0
108110 else
109111 return 1
@@ -167,17 +169,11 @@ run_workflow() {
167169 while true ; do
168170 status=$( gh run view " $run_id " --json status,conclusion --jq ' .status' )
169171 if [[ " $status " == " completed" ]]; then
170- conclusion=$( gh run view " $run_id " --json conclusion --jq ' .conclusion' )
171- if [[ " $conclusion " != " success" ]]; then
172- echo " Workflow failed with conclusion: $conclusion "
173- exit 1
174- fi
175172 break
176173 fi
177174 printf " ."
178175 sleep 30
179176 done
180- echo " "
181177
182178 echo " Workflow completed for tag: $tag "
183179}
You can’t perform that action at this time.
0 commit comments