Skip to content

Commit e1b9534

Browse files
committed
Mark automerge PRs as draft
PRs created by GitHub Actions don't kick off further actions (https://github.com/peter-evans/create-pull-request/blob/d57e551ebc1a16dee0b8c9ea6d24dba7627a6e35/docs/concepts-guidelines.md#triggering-further-workflow-runs). As a workaround, we mark automerge PRs that are created by GitHub actions as draft and trigger the GitHub actions by marking the PR as ready for review. But we don't want to re-trigger testing this when a normal user's PR is marked as ready for review.
1 parent 2eadfe9 commit e1b9534

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/create_automerge_pr.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name: Create automerge PR
99
#
1010
# Example usage in a repository:
1111
#
12+
# ```
1213
# name: Create PR to merge main into release branch
1314
#
1415
# # In the first period after branching the release branch, we typically want to include all changes from `main` also in the release branch. This workflow automatically creates a PR every Monday to merge main into the release branch.
@@ -23,13 +24,21 @@ name: Create automerge PR
2324
# create_merge_pr:
2425
# name: Create PR to merge main into release branch
2526
# uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@main
26-
# if: (github.event_name == 'schedule' && github.repository == 'swiftlang/swift-format') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork
27+
# if: (github.event_name == 'schedule' && github.repository == 'swiftlang/<YOUR REPO NAME>') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork
2728
# permissions:
2829
# contents: write
2930
# pull-requests: write
3031
# with:
3132
# base_branch: release/6.2
32-
33+
# ```
34+
#
35+
# PRs created by GitHub Actions don't kick off further actions (https://github.com/peter-evans/create-pull-request/blob/d57e551ebc1a16dee0b8c9ea6d24dba7627a6e35/docs/concepts-guidelines.md#triggering-further-workflow-runs).
36+
# As a workaround, we mark automerge PRs that are created by GitHub actions as draft and trigger the GitHub actions by marking the PR as ready for review. But we don't want to re-trigger testing this when a normal user's PR is marked as ready for review.
37+
# For this the pull request workflow in the repository needs to add the `ready_for_review` type to its `pull_request` trigger and add the following condition as an `if` condition to all jobs:
38+
#
39+
# ```
40+
# if: (github.event.action != 'ready_for_review') || (github.event.action == 'ready_for_review' && github.event.pull_request.user.login == 'github-actions[bot]')
41+
# ```
3342
on:
3443
workflow_call:
3544
inputs:
@@ -90,4 +99,5 @@ jobs:
9099
--base "${{ inputs.base_branch }}" \
91100
--head "$PR_BRANCH" \
92101
--title 'Merge `${{ inputs.head_branch }}` into `${{ inputs.base_branch }}`' \
93-
--body '${{ inputs.pr_message }}'
102+
--body '${{ inputs.pr_message }}' \
103+
--draft

0 commit comments

Comments
 (0)