What is the difference between `pull_request` and `pull_request_target` in terms of context and permissions?
AdvancedConceptTriggers & Events
Answer
pull_request |
pull_request_target |
|
|---|---|---|
| Workflow file from | PR merge commit | Base branch |
GITHUB_SHA / default checkout |
PR merge ref | Base branch tip |
| Secrets for fork PRs | No | Yes |
GITHUB_TOKEN for fork PRs |
Read-only | Can be read/write |
pull_request_target exists so workflows can label, comment on, or triage fork PRs. It is safe only while it never executes PR code. The moment you check out github.event.pull_request.head.sha and run npm install, make or tests, the attacker's code runs with your secrets and write token.
More on Triggers & Events
How do you trigger a workflow on pushes to `main` and on PRs that target `main`?BeginnerWhat activity types does `pull_request` trigger on by default, and how do you add more?IntermediateHow do `branches` and `branches-ignore` filters work with globs?BeginnerHow do path filters work, and what are their limits?AdvancedHow do you trigger only on version tags, and what is the gotcha with pushing many tags?IntermediateWhat is `workflow_dispatch`, and what input types does it support?Beginner