Skip to content

Commit ed79da5

Browse files
craig[bot]rail
andcommitted
Merge #148541
148541: workflow: check PR base branch r=celiala,jlinder,rickystewart a=rail Bors should not be used for pull requests that do not target the master branch. Previously, bors didn't allow PRs with the `backport` label to be merged, but this was not restrictive enough - one can remove the label and use bors. Now, we check the base branch of the pull request to ensure it is targeting the master branch. Release note: none Epic: none Co-authored-by: Rail Aliiev <[email protected]>
2 parents b90420e + eff710f commit ed79da5

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.github/bors.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ status = [
1919
# r+-ed. If it's still in progress (for e.g. if CI is still running), bors will
2020
# construct the merge commit in parallel and simply wait for success right
2121
# before merging.
22-
pr_status = ["license/cla", "blathers/release-justification-check"]
22+
pr_status = [
23+
"license/cla",
24+
"blathers/release-justification-check",
25+
"check_base_branch",
26+
]
2327

2428
# List of PR labels that may not be attached to a PR when it is r+-ed.
2529
block_labels = ["do-not-merge", "backport"]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Bors
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, edited]
6+
branches: [master]
7+
8+
jobs:
9+
check_base_branch:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check if PR targets master branch
13+
run: |
14+
if [ "${{ github.base_ref }}" != "master" ]; then
15+
echo "::error::Bors cannot be used for this pull request. Pull request must target the 'master' branch. Current target: ${{ github.base_ref }}. You can ignore this check if the pull request is not a backport."
16+
exit 1
17+
else
18+
echo "✅ Pull request correctly targets 'master' branch"
19+
fi

0 commit comments

Comments
 (0)