Skip to content

Commit 82cafa0

Browse files
authored
Merge pull request #15818 from github/repo-sync
repo sync
2 parents 521da8d + 1b22582 commit 82cafa0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,25 @@ on:
685685

686686
{% endnote %}
687687

688+
#### Running your workflow when a pull request merges
689+
690+
When a pull request merges, the pull request is automatically closed. To run a workflow when a pull request merges, use the `pull_request` `closed` event type along with a conditional that checks the `merged` value of the event. For example, the following workflow will run whenever a pull request closes. The `if_merged` job will only run if the pull request was also merged.
691+
692+
```yaml
693+
on:
694+
pull_request:
695+
types:
696+
- closed
697+
698+
jobs:
699+
if_merged:
700+
if: github.event.pull_request.merged == true
701+
runs-on: ubuntu-latest
702+
steps:
703+
- run: |
704+
echo The PR was merged
705+
```
706+
688707
{% data reusables.developer-site.pull_request_forked_repos_link %}
689708

690709
### `pull_request_comment` (use `issue_comment`)
@@ -869,6 +888,25 @@ on:
869888

870889
{% endnote %}
871890

891+
#### Running your workflow when a pull request merges
892+
893+
When a pull request merges, the pull request is automatically closed. To run a workflow when a pull request merges, use the `pull_request_target` `closed` event type along with a conditional that checks the `merged` value of the event. For example, the following workflow will run whenever a pull request closes. The `if_merged` job will only run if the pull request was also merged.
894+
895+
```yaml
896+
on:
897+
pull_request_target:
898+
types:
899+
- closed
900+
901+
jobs:
902+
if_merged:
903+
if: github.event.pull_request_target.merged == true
904+
runs-on: ubuntu-latest
905+
steps:
906+
- run: |
907+
echo The PR was merged
908+
```
909+
872910
### `push`
873911

874912
| Webhook event payload | Activity types | `GITHUB_SHA` | `GITHUB_REF` |

0 commit comments

Comments
 (0)