A workflow needs a reason to run. In GitHub Actions, the on section names events that can start it. An event can be a push to a branch, a change to a pull request, or another supported action.
Continuous Integration · Lesson 2
Workflow Triggers
Learn to predict when a GitHub Actions workflow runs from its event and branch filters.
Checking a Push
Read this excerpt from a workflow. YAML uses the indentation to show that branches is a setting for push.
on:
push:
branches:
- main
This workflow runs when a commit is pushed to the main branch, assuming the workflow is enabled and other required conditions are met. Committing in a local terminal does not send the change to GitHub. The push is what this excerpt watches.
Which action matches that push trigger?
Checking a Pull Request
A second event can cover proposed changes before they are merged. In this excerpt the branch filter applies to the pull request's target branch.
on:
pull_request:
branches:
- main
A proposal from health-page into main matches that filter. With the default activity types, opening the request and pushing another commit to its head branch are examples of changes that can trigger the workflow.
A pull request proposes notes into main. Which name matters for this branch filter?
Reading More Than One Trigger
A file can list both events below the same on key. A pull request run may cover the proposed integration. After a merge updates main, a push run can cover the state now on that branch. These results belong to the event and revision shown in each run.
A workflow has the two triggers shown above. A merge updates main. Which listed event matches that update?
Lesson complete
You finished Workflow Triggers
You can now match a workflow trigger to a repository event.
Read a push event and its branch filter.
Identify the target branch of a pull request trigger.
Connect a workflow result to its triggering event.
Keep your learning progress
Create a free account to save this lesson and continue learning on any device.
Create a free account