ci: skip Docker Hub login on PRs from forks#4304
Merged
Merged
Conversation
GitHub Actions does not expose secrets to workflows triggered by PRs from forked repositories, so docker/login-action fails with "Username and password required" (e.g. PR #4292). Skip the login step when the PR head repo is not this repository; anonymous pulls still work, and push/manifest jobs are unaffected because they only run on master.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docker/login-actionin thetestjob fails withUsername and password requiredfor external contributors' PRs (see PR #4292 run).pushandmanifestjobs are guarded byif: github.ref_name == 'master'and never run on fork PRs, so they are unaffected.Why skipping the login is safe for the
testjobtestjob only runsmake build/make testand never pushes, so authentication is not strictly required.Dockerfile*in this repository are public — Docker Hub library images (alpine,ubuntu,mysql,python,ruby,node,debian,busybox,docker, ...), public vendor images (amazon/aws-cli,datadog/...,confluentinc/...,crossplane/...,summerwind/actions-runner,adoptopenjdk/*,circleci/*,fluent/fluentd,curlimages/curl), GHCR (ghcr.io/actions/actions-runner), Quay (quay.io/argoproj/argocd), and the project's own publicly-pushedchatwork/*images. None of them require authentication.masterstill log in as before). If it ever becomes a real problem we can revisit (e.g. registry mirror, or asking maintainers to retrigger CI from an internal branch).