Update events that trigger workflows docs (#23954)
Co-authored-by: Jacob Wallraff <thyeggman@github.com> Co-authored-by: hubwriter <hubwriter@github.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
When you use the repository's `GITHUB_TOKEN` to perform tasks on behalf of the {% data variables.product.prodname_actions %} app, events triggered by the `GITHUB_TOKEN` will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. For example, if a workflow run pushes code using the repository's `GITHUB_TOKEN`, a new workflow will not run even when the repository contains a workflow configured to run when `push` events occur.
|
||||
When you use the repository's `GITHUB_TOKEN` to perform tasks, events triggered by the `GITHUB_TOKEN` will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. For example, if a workflow run pushes code using the repository's `GITHUB_TOKEN`, a new workflow will not run even when the repository contains a workflow configured to run when `push` events occur.
|
||||
|
||||
@@ -1,34 +1,75 @@
|
||||
## Example: Using a single event
|
||||
### Using a single event
|
||||
|
||||
For example, a workflow with the following `on` value will run when a push is made to any branch in the workflow's repository:
|
||||
|
||||
```yaml
|
||||
# Triggered when code is pushed to any branch in a repository
|
||||
on: push
|
||||
```
|
||||
|
||||
## Example: Using a list of events
|
||||
### Using a multiple events
|
||||
|
||||
You can specify a single event or multiple events. For example, a workflow with the following `on` value will run when a push is made to any branch in the repository or when someone forks the repository:
|
||||
|
||||
```yaml
|
||||
# Triggers the workflow on push or pull request events
|
||||
on: [push, pull_request]
|
||||
on: [push, fork]
|
||||
```
|
||||
|
||||
## Example: Using multiple events with activity types or configuration
|
||||
If you specify multiple events, only one of those events needs to occur to trigger your workflow. If multiple triggering events for your workflow occur at the same time, multiple workflow runs will be triggered.
|
||||
|
||||
If you need to specify activity types or configuration for an event, you must configure each event separately. You must append a colon (`:`) to all events, including events without configuration.
|
||||
### Using activity types
|
||||
|
||||
Some events have activity types that give you more control over when your workflow should run.
|
||||
|
||||
For example, the `issue_comment` event has the `created`, `edited`, and `deleted` activity types. If your workflow triggers on the `label` event, it will run whenever a label is created, edited, or deleted. If you specify the `created` activity type for the `label` event, your workflow will run when a label is created but not when a label is edited or deleted.
|
||||
|
||||
```yaml
|
||||
on:
|
||||
label:
|
||||
types:
|
||||
- created
|
||||
```
|
||||
|
||||
If you specify multiple activity types, only one of those event activity types needs to occur to trigger your workflow. If multiple triggering event activity types for your workflow occur at the same time, multiple workflow runs will be triggered. For example, the following workflow triggers when an issue is opened or labeled. If an issue with two labels is opened, three workflow runs will start: one for the issue opened event and two for the two issue labeled events.
|
||||
|
||||
```yaml
|
||||
on:
|
||||
issue:
|
||||
types:
|
||||
- opened
|
||||
- labeled
|
||||
```
|
||||
|
||||
### Using filters
|
||||
|
||||
Some events have filters that give you more control over when your workflow should run.
|
||||
|
||||
For example, the `push` event has a `branches` filter that causes your workflow to run only when a push to a branch that matches the `branches` filter occurs, instead of when any push occurs.
|
||||
|
||||
```yaml
|
||||
on:
|
||||
# Trigger the workflow on push or pull request,
|
||||
# but only for the main branch
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
- 'releases/**'
|
||||
```
|
||||
|
||||
### Using activity types and filters with multiple events
|
||||
|
||||
If you specify activity types or filters for an event and your workflow triggers on multiple events, you must configure each event separately. You must append a colon (`:`) to all events, including events without configuration.
|
||||
|
||||
For example, a workflow with the following `on` value will run when:
|
||||
|
||||
- A label is created
|
||||
- A push is made to the `main` branch in the repository
|
||||
- A push is made to a {% data variables.product.prodname_pages %}-enabled branch
|
||||
|
||||
```yaml
|
||||
on:
|
||||
label:
|
||||
types:
|
||||
- created
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# Also trigger on page_build, as well as release created events
|
||||
page_build:
|
||||
release:
|
||||
types: # This configuration does not affect the page_build event above
|
||||
- created
|
||||
```
|
||||
|
||||
1
data/reusables/github-actions/branch-paths-filter.md
Normal file
1
data/reusables/github-actions/branch-paths-filter.md
Normal file
@@ -0,0 +1 @@
|
||||
If you use both the `branches` filter and the `paths` filter, the workflow will only run when both filters are satisfied.
|
||||
Reference in New Issue
Block a user