Dive into the essentials of event triggers in GitHub Actions, exploring push, pull_request, workflow_dispatch, and other key concepts. This quiz helps you grasp how different events initiate workflows, enhancing your automation expertise.
Which event trigger starts a workflow when changes are pushed to a repository branch, such as when new code is committed to 'main'?
Explanation: The 'push' event initiates a workflow whenever changes are committed to a branch. 'pull_request' is triggered by pull request actions, not direct pushes. 'workflow_run' refers to completed workflows and is not tied to code commits. 'release' is activated by release creation or publication, not by code pushes.
Suppose a workflow should run only when a pull request is opened or updated, not when code is pushed directly. Which event trigger is most appropriate?
Explanation: 'pull_request' triggers workflows when pull requests are opened, synchronized, or updated. 'push' is for branch commits rather than pull request actions. 'issue_comment' pertains to comments and does not relate to code changes. 'deployment' focuses on deployment events and is unrelated to pull requests.
If you want a workflow to be started manually from the workflow interface, which event trigger should you specify in your workflow configuration?
Explanation: The 'workflow_dispatch' event enables users to manually initiate a workflow from the interface. 'push' and 'schedule' are automatic triggers; the former occurs on code commits, the latter based on preset times. 'manual_trigger' does not exist as a recognized event trigger in configurations.
Which event trigger would you use to automatically run a workflow at regular intervals, such as every night at midnight?
Explanation: 'schedule' uses a cron syntax to automate workflows at set times, perfect for nightly runs. 'pull_request' and 'push' react only to repository activity such as merges or commits. 'commit_event' is not an actual supported event trigger, making it an incorrect choice.
To trigger a workflow only when a release is published, which filter would you use with the 'release' event in your workflow configuration?
Explanation: 'types: [published]' ensures the workflow runs specifically when a release is published. 'branches: [published]' and 'tags: [release]' are invalid or misleading, as releases do not map to branches or tags this way in event filtering. 'actions: [created]' is not a valid filter for the release event context.