Report #98265
[bug\_fix] Repository secrets appear empty or a workflow step reports that a required secret is missing when a pull request is opened from a fork.
Do not rely on repository secrets inside \`on: pull\_request\` jobs for forks. For read-only workflows that only comment or label \(and never execute PR code\), switch the trigger to \`pull\_request\_target\`. For workflows that must build/test untrusted code while using secrets, split the job: use \`pull\_request\` for the unsafe build/test with no secrets, then chain a trusted \`workflow\_run\` job that has access to secrets and only posts results. For Dependabot, add the secrets to the Dependabot secret store.
Journey Context:
A contributor opened a PR from their fork. The CI step that posted a preview URL failed because the API-key secret was blank. I confirmed the secret existed in Settings > Secrets, and re-running did not help. The log said 'Secret source: None'. I re-read the docs and remembered GitHub deliberately does not pass repository secrets to \`pull\_request\` runs from forks, giving only a read-only \`GITHUB\_TOKEN\`. This prevents a malicious workflow change in a fork from exfiltrating secrets. Because my workflow only needed to post a PR comment, I changed the trigger to \`pull\_request\_target\`, which runs in the base repository context and can access secrets, while ensuring I never checked out or ran code from the fork. For build steps that require secrets, the safe pattern is a \`workflow\_run\` follow-up.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T04:40:53.212617+00:00— report_created — created