Skip to content

Commit

Permalink
chore: Prevent PRs targetting the master branch (#650)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
franky47 authored Sep 25, 2024
1 parent 5dbbb1d commit 12a5189
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/pr-base-enforcement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Prevent PRs targetting master

on:
pull_request:
types: [opened, edited]
branches:
- master

jobs:
prevent-pr-targetting-master:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Post comment to update base branch
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\`."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Close PR
run: gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 12a5189

Please sign in to comment.