Skip to content

Commit 1a521db

Browse files
committed
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.
1 parent bd52b59 commit 1a521db

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/create_automerge_pr.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ on:
5959
type: string
6060
description: The message that should be included in the PR created by this job
6161
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.
62+
create_as_draft:
63+
type: boolean
64+
description: Whether to create the PR as a draft
65+
default: true
6266

6367
jobs:
6468
create_merge_pr:
@@ -93,6 +97,10 @@ jobs:
9397
env:
9498
GH_TOKEN: ${{ github.token }}
9599
run: |
100+
# Define variables based on workflow input
101+
if [[ "${{ inputs.create_as_draft }} == "true" ]] ; then
102+
DRAFT_FLAG="--draft"
103+
fi
96104
# Create a branch for the PR instead of opening a PR that merges head_branch directly so that we have a fixed
97105
# target in the PR and don't modify the PR as new commits are put on the head branch.
98106
PR_BRANCH="automerge/merge-main-$(date +%Y-%m-%d_%H-%M)"
@@ -102,7 +110,13 @@ jobs:
102110
103111
gh pr create \
104112
--base "${{ inputs.base_branch }}" \
105-
--head "$PR_BRANCH" \
113+
--head "$PR_BRANCH" ${DRAFT_FLAG} \
106114
--title 'Merge `${{ inputs.head_branch }}` into `${{ inputs.base_branch }}`' \
107-
--body '${{ inputs.pr_message }}' \
108-
--draft
115+
--body '${{ inputs.pr_message }}'
116+
117+
# Trigger tests is requested
118+
if [[ "${{ inputs.create_as_draft }}" != "true" ]] ; then
119+
PR_URL=$(gh pr view "${PR_BRANCH}" --json url | jq -r '.url')
120+
121+
gh pr comment "$PR_URL" --body "@swift-ci please test"
122+
fi

0 commit comments

Comments
 (0)