Interview Prep/GitHub Actions/Triggers & Events

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.

All GitHub Actions questions Roadmap: GitHub Actions

More on Triggers & Events