fix(ci): add retry loop to docker push (handles Gitea registry timeout)
CI / Build Native (push) Successful in 18m38s
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:
+20
-3
@@ -83,9 +83,26 @@ jobs:
|
|||||||
echo "=== Tag ==="
|
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:latest
|
||||||
docker tag shot-crafter-calculator:ci gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:${SHORT_SHA}
|
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
|
push_with_retry() {
|
||||||
docker push gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:${SHORT_SHA}
|
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 ==="
|
echo "=== Logout ==="
|
||||||
docker logout gitea.danielarroyo.cl
|
docker logout gitea.danielarroyo.cl
|
||||||
echo "=== Done ==="
|
echo "=== Done ==="
|
||||||
|
|||||||
Reference in New Issue
Block a user