Skip to content

Commit b18d884

Browse files
Adding additional information for workflow_runs (#18235)
Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
1 parent 54ef0fd commit b18d884

4 files changed

Lines changed: 36 additions & 6 deletions

File tree

content/actions/reference/events-that-trigger-workflows.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,12 +721,14 @@ on:
721721
{% data reusables.github-actions.branch-requirement %}
722722

723723
| Webhook event payload | Activity types | `GITHUB_SHA` | `GITHUB_REF` |
724-
| --------------------- | -------------- | ------------ | -------------|
725-
| [`workflow_run`](/webhooks/event-payloads/#workflow_run) | - n/a | Last commit on default branch | Default branch |
724+
| --------------------- | -------------- | ------------ | -------------|
725+
| [`workflow_run`](/webhooks/event-payloads/#workflow_run) | - `completed`<br/>- `requested` | Last commit on default branch | Default branch |
726+
727+
{% data reusables.developer-site.limit_workflow_to_activity_types %}
726728

727729
If you need to filter branches from this event, you can use `branches` or `branches-ignore`.
728730

729-
In this example, a workflow is configured to run after the separate Run Tests workflow completes.
731+
In this example, a workflow is configured to run after the separate "Run Tests" workflow completes.
730732

731733
```yaml
732734
on:
@@ -740,6 +742,27 @@ on:
740742

741743
{% endif %}
742744

745+
To run a workflow job conditionally based on the result of the previous workflow run, you can use the [`jobs.<job_id>.if`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idif) or [`jobs.<job_id>.steps[*].if`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsif) conditional combined with the `conclusion` of the previous run. For example:
746+
747+
```yaml
748+
on:
749+
workflow_run:
750+
workflows: ["Build"]
751+
types: [completed]
752+
753+
jobs:
754+
on-success:
755+
runs-on: ubuntu-latest
756+
if: {% raw %}${{ github.event.workflow_run.conclusion == 'success' }}{% endraw %}
757+
steps:
758+
...
759+
on-failure:
760+
runs-on: ubuntu-latest
761+
if: {% raw %}${{ github.event.workflow_run.conclusion == 'failure' }}{% endraw %}
762+
steps:
763+
...
764+
```
765+
743766
### Triggering new workflows using a personal access token
744767

745768
{% data reusables.github-actions.actions-do-not-trigger-workflows %} For more information, see "[Authenticating with the GITHUB_TOKEN](/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% if currentVersion == "free-pro-team@latest" %}
22
{% note %}
33

4-
**Note:** Pull requests for {% data variables.product.prodname_dependabot %} version updates will trigger workflow runs with a read-only `GITHUB_TOKEN`. These workflow runs will not be granted access to any secrets.
4+
**Note:** Workflow runs triggered by {% data variables.product.prodname_dependabot %} pull requests run as if they are from a forked repository, and therefore use a read-only `GITHUB_TOKEN`. These workflow runs cannot access any secrets. See ["Keeping your GitHub Actions and workflows secure: Preventing pwn requests"](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) for strategies to keep these workflows secure.
55

66
{% endnote %}
77
{% endif %}

data/reusables/developer-site/pull_request_forked_repos_link.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ When you create a pull request from a forked repository to the base repository,
1111
Workflows don't run on forked repositories by default. You must enable GitHub Actions in the **Actions** tab of the forked repository.
1212

1313
{% data reusables.actions.forked-secrets %} The permissions for the `GITHUB_TOKEN` in forked repositories is read-only. For more information, see "[Authenticating with the GITHUB_TOKEN](/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)."
14+
15+
{% note %}
16+
17+
**Note:** Workflows triggered by {% data variables.product.prodname_dependabot %} pull requests are treated as though they are from a forked repository, and are also subject to these restrictions.
18+
19+
{% endnote %}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
This event occurs when a workflow run is requested or completed, and allows you to execute a workflow based on the finished result of another workflow. A workflow run is triggered regardless of the result of the previous workflow.
12

2-
This event occurs when a workflow run is requested or completed, and allows you to execute a workflow based on the finished result of another workflow. For example, if your `pull_request` workflow generates build artifacts, you can create a new workflow that uses `workflow_run` to analyze the results and add a comment to the original pull request.
3+
For example, if your `pull_request` workflow generates build artifacts, you can create a new workflow that uses `workflow_run` to analyze the results and add a comment to the original pull request.
34

4-
The workflow started by the `workflow_run` event is able to access the secrets and write tokens used by the original workflow.
5+
The workflow started by the `workflow_run` event is able to access secrets and write tokens, even if the previous workflow was not. This is useful in cases where the previous workflow is intentionally not privileged, but you need to take a privileged action in a later workflow.

0 commit comments

Comments
 (0)