ci: add retry with exponential backoff to deploy step (#212)

## Summary

- Replaces curl's built-in `--retry` with a shell loop that retries up
to 5 times on any non-2xx response (not just connection failures)
- Delays increase with each attempt: 10s → 20s → 30s → 40s between
retries
- Exits immediately on success so successful deploys are unaffected
This commit is contained in:
Víctor Falcón 2026-03-07 14:18:14 +00:00 committed by GitHub
parent 93369d8b6f
commit 3cbca1a17d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 31 additions and 16 deletions

View File

@ -274,24 +274,39 @@ jobs:
steps:
- name: Trigger deployment
run: |
response=$(curl -s -w "\n%{http_code}" \
--connect-timeout 30 \
--max-time 120 \
--retry 3 \
--retry-delay 5 \
--retry-connrefused \
-H "Authorization: Bearer ${{ secrets.DEPLOYMENT_TOKEN }}" \
"http://147.93.126.54:8000/api/v1/deploy?uuid=ww00sswosco8w80k08c0occ8&force=false")
max_attempts=5
attempt=1
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt of $max_attempts..."
echo "Response: $body"
echo "HTTP Status: $http_code"
response=$(curl -s -w "\n%{http_code}" \
--connect-timeout 30 \
--max-time 120 \
-H "Authorization: Bearer ${{ secrets.DEPLOYMENT_TOKEN }}" \
"http://147.93.126.54:8000/api/v1/deploy?uuid=ww00sswosco8w80k08c0occ8&force=false")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
echo "Response: $body"
echo "HTTP Status: $http_code"
if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
echo "Deployment triggered successfully!"
exit 0
fi
if [ "$http_code" -lt 200 ] || [ "$http_code" -ge 300 ]; then
echo "Deployment request failed with status $http_code"
exit 1
fi
echo "Deployment triggered successfully!"
if [ $attempt -lt $max_attempts ]; then
delay=$((attempt * 10))
echo "Retrying in ${delay}s..."
sleep $delay
fi
attempt=$((attempt + 1))
done
echo "All $max_attempts attempts failed. Giving up."
exit 1