From 7fb307cdb9e0a6bc4bdf7f973049bb41ad35baa5 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 20 Jun 2024 15:03:08 +0100 Subject: [PATCH] Add a github action to check the base branch It should be very rare that we ever PR into a branch that isn't 'develop', 'staging' or a feature branch, and this will give us a failed check when stacking up PRs on top of one another until the one below it is merged. --- .github/workflows/pull_request_base_branch.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/pull_request_base_branch.yaml diff --git a/.github/workflows/pull_request_base_branch.yaml b/.github/workflows/pull_request_base_branch.yaml new file mode 100644 index 00000000000..b9558bda99f --- /dev/null +++ b/.github/workflows/pull_request_base_branch.yaml @@ -0,0 +1,15 @@ +on: + pull_request: + types: [opened, edited, synchronize] +jobs: + check_base_branch: + name: Check PR base branch + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3 + with: + script: | + const baseBranch = context.payload.pull_request.base.ref; + if (!['develop', 'staging'].includes(baseBranch) && !baseBranch.startsWith('feat/')) { + core.setFailed(`Invalid base branch: ${baseBranch}`); + }