Skip to content

Commit 43612c6

Browse files
committed
Add configurability to the automerger workflow
Add additional configurability to the GitHub automerger workflow to optionally create the PR as non-draft, and to trigger testing by commenting `@swift-ci please test` on the created PR.
1 parent bd52b59 commit 43612c6

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

.github/workflows/create_automerge_pr.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ 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
66+
should_test:
67+
type: boolean
68+
description: Whether the created PR should trigger tests
69+
default: false
6270

6371
jobs:
6472
create_merge_pr:
@@ -93,6 +101,10 @@ jobs:
93101
env:
94102
GH_TOKEN: ${{ github.token }}
95103
run: |
104+
# Define variables based on workflow input
105+
if [[ "${{ inputs.create_as_draft }} == "true" ]] ; then
106+
DRAFT_FLAG="--draft"
107+
fi
96108
# Create a branch for the PR instead of opening a PR that merges head_branch directly so that we have a fixed
97109
# target in the PR and don't modify the PR as new commits are put on the head branch.
98110
PR_BRANCH="automerge/merge-main-$(date +%Y-%m-%d_%H-%M)"
@@ -102,7 +114,13 @@ jobs:
102114
103115
gh pr create \
104116
--base "${{ inputs.base_branch }}" \
105-
--head "$PR_BRANCH" \
117+
--head "$PR_BRANCH" ${DRAFT_FLAG} \
106118
--title 'Merge `${{ inputs.head_branch }}` into `${{ inputs.base_branch }}`' \
107-
--body '${{ inputs.pr_message }}' \
108-
--draft
119+
--body '${{ inputs.pr_message }}'
120+
121+
# Trigger tests is requested
122+
if [[ "${{ inputs.should_test }}" == "true" ]] ; then
123+
PR_URL=$(gh pr view "${PR_BRANCH}" --json url | jq -r '.url')
124+
125+
gh pr comment "$PR_URL" --body "@swift-ci please test"
126+
fi

0 commit comments

Comments
 (0)