Skip to content

Commit

Permalink
add retry logic for 404 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zainasir committed Nov 6, 2024
1 parent f3e9177 commit 3dff871
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/jitpack-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,29 @@ jobs:

- name: Get release tag
id: get_tag
run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Trigger JitPack Build
run: |
TAG=${{ steps.get_tag.outputs.tag }}
JITPACK_BUILD_URL="https://jitpack.io/com/github/cbioportal/cbioportal-frontend/$TAG/build.log"
echo "Triggering JitPack build for $TAG"
curl -I $JITPACK_BUILD_URL
- name: Notify success
run: echo "JitPack build triggered successfully."
MAX_RETRIES=10
RETRY_DELAY=30
COUNTER=0
while [ $COUNTER -lt $MAX_RETRIES ]; do
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$JITPACK_BUILD_URL")
if [ "$HTTP_STATUS" -eq 200 ]; then
echo "Build triggered successfully for version ${TAG}."
exit 0
else
echo "Attempt $((COUNTER+1)) failed with status $HTTP_STATUS: Tag not found yet. Retrying in $RETRY_DELAY seconds..."
((COUNTER++))
sleep $RETRY_DELAY
fi
done
echo "Failed to trigger JitPack build after $MAX_RETRIES attempts."
exit 1

0 comments on commit 3dff871

Please sign in to comment.