diff --git a/.github/workflows/pr-base-enforcement.yml b/.github/workflows/pr-base-enforcement.yml new file mode 100644 index 00000000..d2891e79 --- /dev/null +++ b/.github/workflows/pr-base-enforcement.yml @@ -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 }}