Skip to content

Commit 12a5189

Browse files
authored
chore: Prevent PRs targetting the master branch (#650)
* chore: Prevent PRs targetting the master branch * chore: Escape branch names * chore: Checkout * chore: Don't run on reopen (as you need to reopen to change the base branch)
1 parent 5dbbb1d commit 12a5189

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Prevent PRs targetting master
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited]
6+
branches:
7+
- master
8+
9+
jobs:
10+
prevent-pr-targetting-master:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
14+
- name: Post comment to update base branch
15+
run: gh pr comment ${{ github.event.pull_request.number }} --body "⚠️ Pull requests targetting the \`master\` branch are not allowed. Please update the base branch to \`next\`."
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
- name: Close PR
19+
run: gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }}
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)