Replies: 2 comments 2 replies
-
|
You’re not missing anything, this is intentional behavior by GitHub. Workflows triggered by Secrets are only exposed for trusted events, such as:
This is why some repositories appear to behave differently. In most cases, they are:
So what feels inconsistent is actually GitHub enforcing a strict security boundary between untrusted PR code and sensitive credentials. In short: nothing is broken, GitHub is doing this to keep your secrets safe, even if it feels a bit confusing at first 👍 |
Beta Was this translation helpful? Give feedback.
-
|
GitHub doesn’t expose repository secrets to workflows triggered by pull_request events for security reasons even if the PR is from a branch inside the same repo. Only push events (and pull_request_target, with caution) can access secrets. That’s why your workflow can read secrets on push, but not on pull requests. If you really need secret access during PRs, you’d need to switch to pull_request_target, but be careful because it runs in the context of the base branch and can be risky if contributors can modify the workflow. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Question
What GitHub Actions topic or product is this about?
Workflow Configuration
Discussion Details
Hello,
I've seen some repositories that use repo secrets to publish packages to NuGet, and where the secrets cannot be read from pull requests, both forks but also PR's between 2 branches in the repo (like from 'dev' to 'main') but the action is able to read the secrets on push.
This seems odd to me as I can't seem to replicate the functionality.
Example yml:
What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions