fix(ci): add retry loop to docker push (handles Gitea registry timeout)
CI / Build Native (push) Successful in 18m38s

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}).
This commit is contained in:
2026-08-12 21:12:22 -04:00
parent 9bae7dfe29
commit ee1363535c
+20 -3
View File
@@ -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 ==="