diff --git a/content/actions/writing-workflows/workflow-syntax-for-github-actions.md b/content/actions/writing-workflows/workflow-syntax-for-github-actions.md index 40afb8c36b74..c59a50d2181b 100644 --- a/content/actions/writing-workflows/workflow-syntax-for-github-actions.md +++ b/content/actions/writing-workflows/workflow-syntax-for-github-actions.md @@ -236,6 +236,10 @@ A boolean specifying whether the secret must be supplied. {% data reusables.actions.workflows.section-specifying-branches %} +## `on.workflow_run.workflows` + +{% data reusables.actions.workflow-run.section-specifying.workflows %} + ## `on.workflow_dispatch` {% data reusables.actions.workflow-dispatch %} @@ -1182,7 +1186,7 @@ Allowed expression contexts: `github`, `needs`, and `secrets`. ## Filter pattern cheat sheet -You can use special characters in path, branch, and tag filters. +You can use special characters in path, branch, tag, and workflow name filters. * `*`: Matches zero or more characters, but does not match the `/` character. For example, `Octo*` matches `Octocat`. * `**`: Matches zero or more of any character. diff --git a/data/reusables/actions/workflow-run/section-specifying.workflows.md b/data/reusables/actions/workflow-run/section-specifying.workflows.md new file mode 100644 index 000000000000..33c7bf3f6127 --- /dev/null +++ b/data/reusables/actions/workflow-run/section-specifying.workflows.md @@ -0,0 +1,31 @@ + +When using the `workflow_run` event, you can specify which workflows can trigger your workflow. + +The `workflows` filters accept glob patterns that use characters like `*`, `**`, `+`, `?`, `!` and others to match more than one workflow 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 [AUTOTITLE](/actions/writing-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: + +```yaml +on: + workflow_run: + workflows: ["Build"] + types: [requested] +``` + +A workflow with the following trigger will only run when a workflow whose name starts with `Build` completed: + +```yaml +on: + workflow_run: + workflows: ["Build*"] + types: [completed] +``` + +A workflow with the following trigger will only run when the workflow named `Build C++` completed: + +```yaml +on: + workflow_run: + workflows: ["Build C\+\+"] + types: [completed] +```