GitHub Actions: Triggers — push and pull_request
A trigger is the event that starts a workflow. Push and pull request are the two triggers most workflows use.
Run on push
Every push to any branch starts this workflow.
on: pushRun on pull request
Opening a pull request starts this workflow. New pushes to it start it again.
on: pull_requestRun on either event
A list under on holds both triggers.
on: [push, pull_request]The two-line form
The same list can be written over two lines.
on:
push:
pull_request:Example
name: Triggers
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '24'
- run: npm testKey points
- Use push to run a workflow when code is pushed to the repo.
- Use pull_request to run a workflow when a pull request opens or changes.
- A pull request is a proposal to merge one branch into another.
- List more than one trigger to run on either event.
- A workflow with no matching trigger never starts.
- Triggers are the on line of the workflow, stated in plain words.
In this example, the workflow is saved as .github/workflows/triggers.yml. Its on line lists push and pull_request, so it runs on every push and on every pull request change. The test job fetches the code, sets up Node 24, and runs the tests. The output shows both tests passing.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
Which trigger runs a workflow when a pull request opens?