Split 'Events that trigger workflows' into two articles (#24392)
This commit is contained in:
22
data/reusables/github-actions/actions-activity-types.md
Normal file
22
data/reusables/github-actions/actions-activity-types.md
Normal file
@@ -0,0 +1,22 @@
|
||||
Some events have activity types that give you more control over when your workflow should run. Use `on.<event_name>.types` to define the type of event activity that will trigger a workflow 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
|
||||
```
|
||||
|
||||
For more information about each event and their activity types, see "[Events that trigger workflows](/actions/using-workflows/events-that-trigger-workflows)."
|
||||
11
data/reusables/github-actions/actions-filters.md
Normal file
11
data/reusables/github-actions/actions-filters.md
Normal file
@@ -0,0 +1,11 @@
|
||||
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:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'releases/**'
|
||||
```
|
||||
18
data/reusables/github-actions/actions-multiple-types.md
Normal file
18
data/reusables/github-actions/actions-multiple-types.md
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
page_build:
|
||||
```
|
||||
@@ -1,75 +1,19 @@
|
||||
### 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
|
||||
on: push
|
||||
```
|
||||
{% data reusables.github-actions.on-single-example %}
|
||||
|
||||
### Using 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
|
||||
on: [push, fork]
|
||||
```
|
||||
|
||||
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.
|
||||
{% data reusables.github-actions.on-multiple-example %}
|
||||
|
||||
### 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
|
||||
```
|
||||
{% data reusables.github-actions.actions-activity-types %}
|
||||
|
||||
### 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:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'releases/**'
|
||||
```
|
||||
{% data reusables.github-actions.actions-filters %}
|
||||
|
||||
### 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
|
||||
page_build:
|
||||
```
|
||||
{% data reusables.github-actions.actions-multiple-types %}
|
||||
7
data/reusables/github-actions/on-multiple-example.md
Normal file
7
data/reusables/github-actions/on-multiple-example.md
Normal file
@@ -0,0 +1,7 @@
|
||||
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
|
||||
on: [push, fork]
|
||||
```
|
||||
|
||||
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.
|
||||
5
data/reusables/github-actions/on-single-example.md
Normal file
5
data/reusables/github-actions/on-single-example.md
Normal file
@@ -0,0 +1,5 @@
|
||||
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
|
||||
on: push
|
||||
```
|
||||
34
data/reusables/github-actions/workflow-dispatch-inputs.md
Normal file
34
data/reusables/github-actions/workflow-dispatch-inputs.md
Normal file
@@ -0,0 +1,34 @@
|
||||
When using the `workflow_dispatch` event, you can optionally specify inputs that are passed to the workflow.
|
||||
|
||||
The triggered workflow receives the inputs in the `github.event.inputs` context. For more information, see "[Contexts](/actions/learn-github-actions/contexts#github-context)."
|
||||
|
||||
```yaml
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
logLevel:
|
||||
description: 'Log level'
|
||||
required: true
|
||||
default: 'warning' {% ifversion fpt or ghec or ghes > 3.3 or ghae-issue-5511 %}
|
||||
type: choice
|
||||
options:
|
||||
- info
|
||||
- warning
|
||||
- debug {% endif %}
|
||||
tags:
|
||||
description: 'Test scenario tags'
|
||||
required: false {% ifversion fpt or ghec or ghes > 3.3 or ghae-issue-5511 %}
|
||||
type: boolean
|
||||
environment:
|
||||
description: 'Environment to run tests against'
|
||||
type: environment
|
||||
required: true {% endif %}
|
||||
|
||||
jobs:
|
||||
print-tag:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Print the input tag to STDOUT
|
||||
run: echo {% raw %} The tag is ${{ github.event.inputs.tag }} {% endraw %}
|
||||
```
|
||||
Reference in New Issue
Block a user