You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add option for automerger workflow to create non-draft PRs
Add an option to the GitHub automerger workflow to optionally create a
PR as non-draft. When this is the case, the tests will be demanded by
commenting `@swift-ci please test` on the created PR.
Copy file name to clipboardExpand all lines: .github/workflows/create_automerge_pr.yml
+32-10Lines changed: 32 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -30,16 +30,24 @@ name: Create automerge PR
30
30
# pull-requests: write
31
31
# with:
32
32
# base_branch: release/6.2
33
+
# # Optional: Set to false to automatically trigger tests via "@swift-ci please test" comment
34
+
# # create_as_draft: false
33
35
# ```
34
36
#
35
37
# 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. `ready_for_review` must be added to the PR types for this purpose, eg.
37
-
# ```
38
-
# on:
39
-
# pull_request:
40
-
# types: [..., ready_for_review]
41
-
# ```
42
-
# Unfortunately this will also re-trigger testing evenon a normal user's PR (which may have already been tested), but skipping them causes the checks to reset so this is the best we can do for now.
38
+
# This workflow provides two approaches to trigger testing on automerge PRs:
39
+
#
40
+
# 1. **Draft PR approach (default)**: PRs are created as drafts and testing is triggered by marking the PR as ready for review.
41
+
# For this approach, `ready_for_review` must be added to the PR types, eg.
42
+
# ```
43
+
# on:
44
+
# pull_request:
45
+
# types: [..., ready_for_review]
46
+
# ```
47
+
# Unfortunately this will also re-trigger testing even on a normal user's PR (which may have already been tested), but skipping them causes the checks to reset so this is the best we can do for now.
48
+
#
49
+
# 2. **Auto-trigger approach**: When `create_as_draft` is set to `false`, the workflow will only trigger Swift CI tests by commenting "@swift-ci please test" on the created PR. This does not trigger any GitHub actions.
50
+
# This requires the repository to have the github-actions bot configured to respond to such comments.
43
51
44
52
permissions:
45
53
contents: read
@@ -59,6 +67,10 @@ on:
59
67
type: string
60
68
description: The message that should be included in the PR created by this job
61
69
default: This PR was automatically opened by a GitHub action. Review the changes included in this PR and determine if they should be included in the release branch. If yes, merge the PR. Otherwise revert changes that should not be included on this branch.
70
+
create_as_draft:
71
+
type: boolean
72
+
description: Whether to create the PR as a draft
73
+
default: true
62
74
63
75
jobs:
64
76
create_merge_pr:
@@ -93,6 +105,10 @@ jobs:
93
105
env:
94
106
GH_TOKEN: ${{ github.token }}
95
107
run: |
108
+
# Define variables based on workflow input
109
+
if [[ "${{ inputs.create_as_draft }} == "true" ]] ; then
110
+
DRAFT_FLAG="--draft"
111
+
fi
96
112
# Create a branch for the PR instead of opening a PR that merges head_branch directly so that we have a fixed
97
113
# target in the PR and don't modify the PR as new commits are put on the head branch.
0 commit comments