Skip to content

Chapter 2 of 7

Triggering Workflows

Every workflow must begin with an on: clause that lists the events which cause it to run. Common triggers include push, pull_request, and workflow_dispatch. The workflow_dispatch event in particular allows a workflow to be started manually from the Actions tab in the GitHub UI, from the REST API, or from the GitHub CLI, making it a convenient hook for on-demand jobs.

Scheduled runs are configured with on: schedule:, which accepts POSIX cron syntax evaluated against UTC. For example, on: schedule: - cron: '30 2 * * *' would run the workflow daily at 02:30 UTC. Push and pull_request triggers can be narrowed with branch filters, such as on: push: branches: [main] to limit runs to commits pushed to the main branch, or on: pull_request: branches: [main, develop] to scope pull request runs to those target branches. By default both events run on all branches, but explicit branches or paths filters quickly override that behavior.

Path-based filtering offers finer control. The paths: filter under on: push restricts the trigger to commits that change files matching the given glob patterns, while paths-ignore: excludes commits that modify the listed patterns. Together, these allow you to keep expensive workflows from running when only unrelated files such as documentation or images have been touched.

All chapters
  1. 1GitHub Actions Foundations
  2. 2Triggering Workflows
  3. 3Jobs, Matrices, Concurrency, and Conditions
  4. 4Environment Variables, Outputs, and Context References
  5. 5Permissions, Tokens, and Security
  6. 6Artifacts, Caching, and Service Containers
  7. 7Reusable Workflows, Environments, and Deployments

Drill it

Reading is not remembering. These come from the Github Actions Ci Cd Recipes deck:

Q

What is GitHub Actions?

A CI/CD and workflow automation platform built into GitHub that runs jobs in response to repository events using YAML-defined workflows stored in .github/workfl...

Q

What file extension do GitHub Actions workflow files use?

.yaml or .yml, stored under .github/workflows/ in the repository.

Q

What is a workflow in GitHub Actions?

An automated, configurable process defined by a YAML file that runs one or more jobs and is triggered by events.

Q

What is a job in GitHub Actions?

A set of steps in a workflow that execute on the same runner; jobs run in parallel by default unless dependencies are declared with needs:.