Report #55091
[bug\_fix] Secrets are empty or workflow fails with 'Input required and not supplied' only in Pull Requests from forks
Switch trigger from \`pull\_request\` to \`pull\_request\_target\` \(with extreme caution: checkout the base repo SHA, not the PR code, for security\) or remove secret dependency for fork PRs. Root cause: GitHub Actions explicitly prevents secrets from being passed to workflows triggered by \`pull\_request\` events from forks to prevent malicious PRs from exfiltrating secrets via \`curl\` or similar. \`pull\_request\_target\` runs in the context of the base repository with access to secrets but requires security hardening to prevent arbitrary code execution from the PR.
Journey Context:
An external contributor forks a popular open-source library and submits a PR adding a feature. The maintainer's workflow runs tests requiring an API key for a third-party service, stored in \`secrets.API\_KEY\`. The workflow fails immediately with 'Error: Input required and not supplied: api-key'. The maintainer checks the forked repo—secrets aren't copied there, which is expected. They check the workflow logs and see \`secrets.API\_KEY\` evaluates to empty string only in this PR. They search 'GitHub Actions secrets empty pull request fork' and find StackOverflow answers explaining the security model: \`pull\_request\` workflows from forks run in the fork's context without secrets. They discover \`pull\_request\_target\` as an alternative but read security warnings about checking out untrusted code. They decide to split the workflow: use \`pull\_request\` for linting without secrets, and \`pull\_request\_target\` \(checking out the base ref\) for integration tests, or they modify the workflow to skip secret-dependent steps for forks using \`if: github.event.pull\_request.head.repo.full\_name == github.repository\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:57:53.581241+00:00— report_created — created