Skip to content

Commit 68fd30c

Browse files
authored
Skip Docker Hub login for forked PRs (#2629)
Forked PRs cannot access GitHub secrets (DOCKERHUB_USERNAME and DOCKERHUB_TOKEN), causing the Docker login step to fail with 'Username and password required'. This blocks external contributions. This change makes the Docker Hub login conditional: - Skips login for forked PRs (secrets unavailable) - Runs login for PRs from branches in the main repo - Runs login for push events, tags, and manual workflows Docker Hub authentication helps avoid rate limits (429 errors) when pulling base images like python:* and nvidia/cuda:* during builds. Forked PRs will use anonymous Docker Hub pulls and may occasionally hit rate limits, but this is an acceptable trade-off to unblock public contributions. Fixes the issue reported in PR #2619 where forked PRs fail at the Docker login step in CI. Co-authored-by: Mark Phelps <mphelps@cloudflare.com>
1 parent 471de5b commit 68fd30c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ jobs:
172172
fetch-depth: 0
173173
- name: Login to Docker Hub
174174
uses: docker/login-action@v3
175+
# Skip Docker Hub login for forked PRs (secrets not available)
176+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
175177
with:
176178
registry: index.docker.io
177179
username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -219,6 +221,8 @@ jobs:
219221
fetch-depth: 0 # needed for goreleaser version determination
220222
- name: Login to Docker Hub
221223
uses: docker/login-action@v3
224+
# Skip Docker Hub login for forked PRs (secrets not available)
225+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
222226
with:
223227
registry: index.docker.io
224228
username: ${{ secrets.DOCKERHUB_USERNAME }}

0 commit comments

Comments
 (0)