How to Inspect the Event Payload in GitHub Actions
The github.event context is the full webhook payload; dumping it shows exactly which fields exist for the event that triggered the run.
Print ${{ toJSON(github.event) }}, or cat the file at $GITHUB_EVENT_PATH. Both show the raw payload so you can confirm a field like github.event.pull_request.merged is actually present.
Steps
- Add a step that dumps the event payload.
- Find the field path you need (it differs per event type).
- Use
jqon$GITHUB_EVENT_PATHto extract a single value.
Workflow
.github/workflows/ci.yml
steps:
- name: Dump the event payload
env:
EVENT: ${{ toJSON(github.event) }}
run: echo "$EVENT"
- name: Pull one field out with jq
run: |
jq '.action, .pull_request.number' "$GITHUB_EVENT_PATH"Gotchas
- Payload shape depends on the event; a
pushpayload has nopull_requestobject. github.event.head_commitis null for many events, which breaks naive[skip ci]checks.- The file at
$GITHUB_EVENT_PATHis the same data the context exposes.
Related guides
How to Print the Full Context With toJSON in GitHub ActionsDump an entire GitHub Actions context (github, env, job, steps, runner) to the log with toJSON so you can see…
How to Debug a Skipped Job by Checking the if Condition in GitHub ActionsFigure out why a GitHub Actions job shows up as skipped by inspecting its if condition and needs results, the…