Use on
to define a trigger that runs the workflow.
push
and pull_request
are the two repository event triggers that cause a workflow to execute.
You can also manually execute a workflow, with workflow_dispatch
.
Example usage
In the following example, a workflow runs in response to a pull request event to the main
branch of a repository, or it can be manually executed.
on: pull_request: branches: - 'main' workflow_dispatch:
In the following example, a workflow runs in response to a push event to either a repository demo
branch or to any file in its test
directory.
on: push: branches: - 'demo' - 'test/**'
The *
wildcard matches any character, but does not match /
. The **
matches any character, including /
.
Definition of a triggering event
The table below defines when a push event results in a workflow run:
on.push.branches input |
Push to repository branch | Workflow result |
---|---|---|
|
|
Runs |
|
|
Does not run |
|
|
Runs |
|
|
Runs |
|
|
Runs |
|
Any branch |
Runs |