What is the purpose of 'github.event' context in GitHub Actions workflows?
Select an answer to reveal the explanation.
Short Explanation and Infographic
github.event is the raw webhook payload. When a PR opens, github.event has all the PR data — title, number, base branch, labels, author. When a push happens, it has the commit info. You use it to make decisions: 'if this PR targets main and has the release label, run the release workflow'.
Full explanation below image
Full Explanation
The 'github.event' context in GitHub Actions provides access to the complete webhook event payload that triggered the workflow run. Content varies by trigger event: (1) For 'push' events: github.event.commits (array of pushed commits), github.event.before/after (SHA hashes), github.event.pusher. (2) For 'pull_request' events: github.event.pull_request (PR details including number, title, labels, base/head branches). (3) For 'issues' events: github.event.issue (issue details). (4) For 'release' events: github.event.release (release metadata). Use cases: extract PR title to set a variable, check which files changed in a push, get issue labels to route to appropriate handler, extract release tag to publish. The event name (push, pull_request, etc.) is available separately as 'github.event_name'.