From ee1363535c3b903ebfe320e1b65a978a92ddef89 Mon Sep 17 00:00:00 2001 From: Daniel Arroyo Date: Wed, 12 Aug 2026 21:12:22 -0400 Subject: [PATCH] fix(ci): add retry loop to docker push (handles Gitea registry timeout) The Gitea Container Registry responded with 'net/http: timeout awaiting response headers' midway through the push. The image uploads ~50MB of layers, and the registry can be slow under load. Add a push_with_retry() shell function that retries each push up to 3 times with 15s backoff. Most importantly, it retries for both the 'latest' and the SHA tag, so a partial failure doesn't leave the registry in a half-pushed state. Uses POSIX sh-compatible while loop (no bashisms like {1..3}). --- .gitea/workflows/ci.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index e689ac0..713c0f0 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -83,9 +83,26 @@ jobs: echo "=== Tag ===" docker tag shot-crafter-calculator:ci gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest docker tag shot-crafter-calculator:ci gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:${SHORT_SHA} - echo "=== Push ===" - docker push gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest - docker push gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:${SHORT_SHA} + + push_with_retry() { + local ref="$1" + local attempt=1 + local max_attempts=3 + while [ $attempt -le $max_attempts ]; do + echo "=== Push (attempt $attempt/$max_attempts): $ref ===" + if docker push "$ref"; then + return 0 + fi + echo "::warning::Push of $ref failed, retrying in 15s..." + sleep 15 + attempt=$((attempt + 1)) + done + echo "::error::Push of $ref failed after $max_attempts attempts" + return 1 + } + + push_with_retry "gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest" + push_with_retry "gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:${SHORT_SHA}" echo "=== Logout ===" docker logout gitea.danielarroyo.cl echo "=== Done ==="