From 3cbca1a17d0d5b898f803714b9916cf8cfddaa5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Sat, 7 Mar 2026 14:18:14 +0000 Subject: [PATCH] ci: add retry with exponential backoff to deploy step (#212) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 --- .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd69490a..6a3aa7ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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