Report #3788
[bug\_fix] Workflows triggered by pull requests from forks fail with 'Input required and not supplied: token' or show empty values for secrets that work on local branches.
For workflows that must access secrets on fork PRs \(e.g., to post a comment or add a label\), change the trigger from \`pull\_request\` to \`pull\_request\_target\`, which runs in the base repository context and has access to secrets. However, never checkout or execute untrusted code from the PR head in a \`pull\_request\_target\` workflow. For build/test workflows that don't need secrets, remove the secret dependency. Alternatively, use the \`workflow\_run\` event to split the workflow into an untrusted part and a trusted part that accesses secrets.
Journey Context:
A maintainer has a workflow that triggers on \`pull\_request\` events to run tests and then post a coverage report as a PR comment using a Personal Access Token stored in \`secrets.PAT\`. When the maintainer opens a PR from a branch within the repository, it works perfectly. However, when an external contributor opens a PR from their fork, the workflow fails at the commenting step with 'Error: Input required and not supplied: token'. The developer checks the workflow logs and sees that the secret is indeed empty. They initially suspect a typo in the secret name or that the secret is not set at the organization level. After verifying the secret exists, they search for 'GitHub Actions secrets empty on pull request' and find documentation explaining that for security reasons, workflows triggered by the \`pull\_request\` event from forks do not have access to secrets, preventing malicious PRs from exfiltrating credentials. The developer realizes they need the secret to post the comment. They refactor the workflow to use \`pull\_request\_target\`, which runs in the context of the base repository and has access to secrets, but they carefully structure it to only checkout the base code or use the GitHub API to comment without executing the PR's code, mitigating the security risk while enabling the functionality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:13:04.148151+00:00— report_created — created