Interview Prep/Git & GitHub/GitHub, Actions and Pull Request Issues

A PR from a fork fails with `Error: Input required and not supplied: token` or empty secrets, while PRs from branches pass.

IntermediateTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → For pull_request events from forks, GitHub does not pass repository secrets and gives a read-only GITHUB_TOKEN. This protects secrets from untrusted code in the fork.

Diagnose → github.event.pull_request.head.repo.fork == true and the secret expands to empty.

Fix → Make fork PR jobs work without secrets (skip deploy/publish steps with if: github.event.pull_request.head.repo.full_name == github.repository). If you need privileged actions like labeling or commenting, use pull_request_target or a workflow_run follow-up without checking out and executing the fork's code.

Prevent → Never combine pull_request_target with actions/checkout of github.event.pull_request.head.sha and running its build — that's the classic "pwn request".

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues