How GitHub Actions triggers and events work
push event, pull_request event, workflow_dispatch, schedule cron, event filters, branch filtering, path filtering
The on Block Controls Everything
The on block determines when your workflow runs. Choosing the right trigger prevents unnecessary runs and keeps your free tier usage low.
Common Triggers
on:
push:
branches: [main, develop]
paths:
- 'src/**'
pull_request:
branches: [main]
schedule:
- cron: '0 6 * * 1' # Every Monday at 06:00 UTC
workflow_dispatch: # Manual trigger from GitHub UIpush โ fires when commits are pushed. Add branches to limit scope. Add paths to only trigger when specific files change โ useful for monorepos.
pull_request โ fires when a PR is opened, updated, or synchronized. Ideal for running tests on proposed changes before merge.
schedule โ uses standard cron syntax. Useful for nightly builds, dependency audits, or cleanup jobs.
workflow_dispatch โ adds a manual trigger button in the GitHub UI. You can define inputs to parameterize the run.
Combining Triggers
A single workflow can listen to multiple events simultaneously. List them as sibling keys under on. Each event can have its own filters. The workflow runs once per matching event regardless of how many are listed.
