Report #14755
[bug\_fix] Workflow fails with 'Resource not accessible by integration' when attempting to comment on a PR, add labels, or access repository secrets during a pull\_request event triggered from a forked repository.
Use the \`pull\_request\_target\` event \(with extreme caution to avoid executing untrusted code with elevated permissions by checking out the base ref rather than the PR ref\) or use a two-workflow pattern where the untrusted \`pull\_request\` workflow uploads artifacts and a trusted \`workflow\_run\` workflow \(triggered by completion of the first\) downloads the artifacts, accesses secrets, and posts results/comments.
Journey Context:
A maintainer has a workflow that runs integration tests against a live staging database using a secret connection string stored in \`secrets.DATABASE\_URL\`. When team members push to branches within the main repository, the workflow runs fine. However, when an external contributor forks the repo and submits a PR, the workflow fails immediately with 'Error: Input required and not supplied: database-url' or the environment variable is empty. The maintainer initially suspects a typo in the secret name, but after checking the settings, they remember that GitHub intentionally does not pass secrets to workflows triggered by \`pull\_request\` events from forks to prevent 'pwn requests' where malicious code exfiltrates secrets. The maintainer reads the GitHub Security Lab article on preventing pwn requests. They realize \`pull\_request\_target\` runs in the base repo context with access to secrets, but the documentation warns that checking out the PR code with \`actions/checkout\` executes untrusted code with write permissions. To solve this safely, the maintainer implements a secure two-workflow pattern: the first workflow triggers on \`pull\_request\` and runs the untrusted tests in a sandbox without secrets, uploading the test results as artifacts. A second workflow triggers on \`workflow\_run\` \(which runs in the base context with secrets\), downloads the artifacts, and uses the GitHub API to post a comment with the test results on the PR. This allows external PRs to be validated safely without exposing secrets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:20:37.620601+00:00— report_created — created