1
0
mirror of synced 2026-01-05 03:06:35 -05:00
Files
docs/data/reusables/actions/workflows/section-specifying-branches.md
2022-01-20 14:50:21 -06:00

46 lines
2.0 KiB
Markdown

When using the `workflow_run` event, you can specify what branches the triggering workflow must run on in order to trigger your workflow.
The `branches` and `branches-ignore` filters accept glob patterns that use characters like `*`, `**`, `+`, `?`, `!` and others to match more than one branch name. If a name contains any of these characters and you want a literal match, you need to *escape* each of these special characters with `\`. For more information about glob patterns, see the "[Filter pattern cheat sheet](/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet)."
For example, a workflow with the following trigger will only run when the workflow named `Build` runs on a branch whose name starts with `releases/`:
```yaml
on:
workflow_run:
workflows: ["Build"]
types: [requested]
branches:
- 'releases/**'
```
A workflow with the following trigger will only run when the workflow named `Build` runs on a branch that is not named `canary`:
```yaml
on:
workflow_run:
workflows: ["Build"]
types: [requested]
branches-ignore:
- "canary"
```
You cannot use both the `branches` and `branches-ignore` filters for the same event in a workflow. If you want to both include and exclude branch patterns for a single event, use the `branches` filter along with the `!` character to indicate which branches should be excluded.
The order that you define patterns matters.
- A matching negative pattern (prefixed with `!`) after a positive match will exclude the branch.
- A matching positive pattern after a negative match will include the branch again.
For example, a workflow with the following trigger will run when the workflow named `Build` runs on a branch that is named `releases/10` or `releases/beta/mona` but will not `releases/10-alpha`, `releases/beta/3-alpha`, or `main`.
```yaml
on:
workflow_run:
workflows: ["Build"]
types: [requested]
branches:
- 'releases/**'
- '!releases/**-alpha'
```