From 12a51892a24c013f84d240269384f63214b80472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Best?= Date: Wed, 25 Sep 2024 16:11:35 +0200 Subject: [PATCH] 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) --- .github/workflows/pr-base-enforcement.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/pr-base-enforcement.yml 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 }}