Retry Docker Hub login on handshake timeout
Wrap docker/login-action with nick-fields/retry (3 attempts, 15s backoff) so transient DockerHub TLS handshake timeouts do not fail the build.
This commit is contained in:
1 parent
69dc5cf7a6
commit
878ac92948
1 file changed
+75
-72
@@ -1,72 +1,75 @@
|
|||||||
name: Docker
|
name: Docker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "**"
|
- "**"
|
||||||
paths:
|
paths:
|
||||||
- 'shared/**'
|
- 'shared/**'
|
||||||
- 'backend/**'
|
- 'backend/**'
|
||||||
- 'frontend/**'
|
- 'frontend/**'
|
||||||
- 'docker/**'
|
- 'docker/**'
|
||||||
- '.github/workflows/docker.yml'
|
- '.github/workflows/docker.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- master
|
- master
|
||||||
paths:
|
paths:
|
||||||
- 'shared/**'
|
- 'shared/**'
|
||||||
- 'backend/**'
|
- 'backend/**'
|
||||||
- 'frontend/**'
|
- 'frontend/**'
|
||||||
- 'docker/**'
|
- 'docker/**'
|
||||||
- '.github/workflows/docker.yml'
|
- '.github/workflows/docker.yml'
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Docker Build & Push
|
name: Docker Build & Push
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
submodules: false
|
submodules: false
|
||||||
- name: Set up QEMU (multi-arch builds)
|
- name: Set up QEMU (multi-arch builds)
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
uses: docker/setup-qemu-action@v4
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
uses: docker/login-action@v4
|
uses: nick-fields/retry@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
timeout_minutes: 5
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
max_attempts: 3
|
||||||
|
retry_wait_seconds: 15
|
||||||
- name: Extract Docker metadata
|
command: |
|
||||||
id: meta
|
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ vars.DOCKERHUB_USERNAME }}" --password-stdin
|
||||||
uses: docker/metadata-action@v6
|
|
||||||
with:
|
- name: Extract Docker metadata
|
||||||
images: ${{ vars.DOCKERHUB_USERNAME }}/collabtableserver
|
id: meta
|
||||||
tags: |
|
uses: docker/metadata-action@v6
|
||||||
type=ref,event=branch
|
with:
|
||||||
type=sha,prefix=sha-,format=short
|
images: ${{ vars.DOCKERHUB_USERNAME }}/collabtableserver
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
- name: Build and push
|
type=sha,prefix=sha-,format=short
|
||||||
uses: docker/build-push-action@v7
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
with:
|
|
||||||
context: .
|
- name: Build and push
|
||||||
file: ./docker/Dockerfile
|
uses: docker/build-push-action@v7
|
||||||
platforms: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
with:
|
||||||
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
context: .
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
file: ./docker/Dockerfile
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
platforms: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
||||||
cache-from: type=registry,ref=${{ vars.DOCKERHUB_USERNAME }}/collabtableserver:buildcache
|
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||||
cache-to: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && format('type=registry,ref={0}/collabtableserver:buildcache,mode=max', vars.DOCKERHUB_USERNAME) || '' }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
provenance: false
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=registry,ref=${{ vars.DOCKERHUB_USERNAME }}/collabtableserver:buildcache
|
||||||
|
cache-to: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && format('type=registry,ref={0}/collabtableserver:buildcache,mode=max', vars.DOCKERHUB_USERNAME) || '' }}
|
||||||
|
provenance: false
|
||||||
Reference in new issue
Block a user