ci: retry Docker Hub login to tolerate transient docker.io timeouts

One matrix job intermittently failed at the login step with
'Get "https://registry-1.docker.io/v2/": context deadline exceeded'
while sibling jobs authenticated fine with the same secrets — a
transient network blip, not a credentials problem. Replace
docker/login-action with a `docker login --password-stdin` retry
loop (5 attempts, 10s backoff) so transient failures self-heal.
This commit is contained in:
taylanbakircioglu
2026-06-02 15:07:05 +03:00
parent d5f9b1833d
commit 575f8dcda1
+18 -4
View File
@@ -51,10 +51,24 @@ jobs:
run: echo "TAG=$(date +'%Y%m%d.%H%M')-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
# Retry to tolerate transient docker.io timeouts, e.g.
# 'Get "https://registry-1.docker.io/v2/": context deadline exceeded'.
# Credentials are written to ~/.docker/config.json, which buildx
# (docker/build-push-action) reads for the push.
for attempt in 1 2 3 4 5; do
if echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin; then
echo "Logged in to Docker Hub on attempt $attempt"
exit 0
fi
echo "Docker Hub login attempt $attempt failed; retrying in 10s..."
sleep 10
done
echo "::error::Docker Hub login failed after 5 attempts"
exit 1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3