ci(docker): add retries for login and push on flaky network
Our upstream is dropping TCP SYNs to github.com/ghcr.io often enough that single docker login/push attempts time out. Wrap in a 5-attempt retry loop with 15s backoff. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a17ca1b90c
commit
a2fa311a5d
40
.github/workflows/docker.yml
vendored
40
.github/workflows/docker.yml
vendored
|
|
@ -29,7 +29,15 @@ jobs:
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
ACTOR: ${{ github.actor }}
|
ACTOR: ${{ github.actor }}
|
||||||
run: echo "$TOKEN" | docker login ghcr.io -u "$ACTOR" --password-stdin
|
run: |
|
||||||
|
for i in 1 2 3 4 5; do
|
||||||
|
if echo "$TOKEN" | docker login ghcr.io -u "$ACTOR" --password-stdin; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "login attempt $i failed, retrying in 15s"
|
||||||
|
sleep 15
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Build + push api
|
- name: Build + push api
|
||||||
env:
|
env:
|
||||||
|
|
@ -37,8 +45,14 @@ jobs:
|
||||||
SHA: ${{ github.sha }}
|
SHA: ${{ github.sha }}
|
||||||
run: |
|
run: |
|
||||||
docker build -f deploy/Dockerfile.api -t ghcr.io/$OWNER/food-market-api:$SHA -t ghcr.io/$OWNER/food-market-api:latest .
|
docker build -f deploy/Dockerfile.api -t ghcr.io/$OWNER/food-market-api:$SHA -t ghcr.io/$OWNER/food-market-api:latest .
|
||||||
docker push ghcr.io/$OWNER/food-market-api:$SHA
|
for tag in $SHA latest; do
|
||||||
docker push ghcr.io/$OWNER/food-market-api:latest
|
for i in 1 2 3 4 5; do
|
||||||
|
if docker push ghcr.io/$OWNER/food-market-api:$tag; then break; fi
|
||||||
|
echo "push $tag attempt $i failed, retrying in 15s"
|
||||||
|
sleep 15
|
||||||
|
[ $i -eq 5 ] && exit 1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
web:
|
web:
|
||||||
name: Web image
|
name: Web image
|
||||||
|
|
@ -50,7 +64,15 @@ jobs:
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
ACTOR: ${{ github.actor }}
|
ACTOR: ${{ github.actor }}
|
||||||
run: echo "$TOKEN" | docker login ghcr.io -u "$ACTOR" --password-stdin
|
run: |
|
||||||
|
for i in 1 2 3 4 5; do
|
||||||
|
if echo "$TOKEN" | docker login ghcr.io -u "$ACTOR" --password-stdin; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "login attempt $i failed, retrying in 15s"
|
||||||
|
sleep 15
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Build + push web
|
- name: Build + push web
|
||||||
env:
|
env:
|
||||||
|
|
@ -58,5 +80,11 @@ jobs:
|
||||||
SHA: ${{ github.sha }}
|
SHA: ${{ github.sha }}
|
||||||
run: |
|
run: |
|
||||||
docker build -f deploy/Dockerfile.web -t ghcr.io/$OWNER/food-market-web:$SHA -t ghcr.io/$OWNER/food-market-web:latest .
|
docker build -f deploy/Dockerfile.web -t ghcr.io/$OWNER/food-market-web:$SHA -t ghcr.io/$OWNER/food-market-web:latest .
|
||||||
docker push ghcr.io/$OWNER/food-market-web:$SHA
|
for tag in $SHA latest; do
|
||||||
docker push ghcr.io/$OWNER/food-market-web:latest
|
for i in 1 2 3 4 5; do
|
||||||
|
if docker push ghcr.io/$OWNER/food-market-web:$tag; then break; fi
|
||||||
|
echo "push $tag attempt $i failed, retrying in 15s"
|
||||||
|
sleep 15
|
||||||
|
[ $i -eq 5 ] && exit 1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue