From 43255e5de8edd7c1f01965c7fc306bdfd0fb4d28 Mon Sep 17 00:00:00 2001 From: Jason Raveling Date: Thu, 22 Jan 2026 11:15:00 -0600 Subject: [PATCH] ci(branch protection): add workflow to check merge request source branch --- .../workflows/branch-protection-warning.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/branch-protection-warning.yml diff --git a/.github/workflows/branch-protection-warning.yml b/.github/workflows/branch-protection-warning.yml new file mode 100644 index 0000000..197f73b --- /dev/null +++ b/.github/workflows/branch-protection-warning.yml @@ -0,0 +1,21 @@ +name: "Check if merging to 'main' from 'release' branch" + +on: + pull_request: + branches: [main] # The branch to protect. + +jobs: + restrict-to-merge-branch-main: + runs-on: ubuntu-latest + + # To prevent a merge on failure, branch protection must be enabled in GitHub. If branch + # protection is disabled, this will fail with a red X but nothing prevents you from merging + # anyway. + steps: + - name: Check merge branch + if: github.event.pull_request.base.ref == 'main' + run: | + if [ "${{ github.event.pull_request.head.ref }}" != "release" ]; then + echo "Merges to 'main' are only allowed from the 'release' branch." + exit 1 + fi