From 7cd5a1776dd3ea8874e5642fe05f144d000722de Mon Sep 17 00:00:00 2001 From: Jason Raveling Date: Thu, 22 Jan 2026 13:28:18 -0600 Subject: [PATCH] ci(branch protection): adds input for configuration --- .../workflows/branch-protection-warning.yml | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/branch-protection-warning.yml b/.github/workflows/branch-protection-warning.yml index 96cff8b..39c46f4 100644 --- a/.github/workflows/branch-protection-warning.yml +++ b/.github/workflows/branch-protection-warning.yml @@ -1,23 +1,30 @@ name: "Check if merging to 'main' from 'release' branch" on: - pull_request: - branches: # These should be primary branch names. - - main - - master + workflow_call: + inputs: + primary_branch: + description: 'The name of the primary branch this workflow will run on.' + required: false + type: string + default: 'main' + +permissions: + contents: read jobs: - protect-primary-branch: - runs-on: ubuntu-latest + protect-primary-branch: + 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 + # 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 == ${{ inputs.primary_branch }} + run: | + if [ "${{ github.event.pull_request.head.ref }}" != "release" ]; then + echo "Merges to '${{ inputs.primary_branch }}' are only allowed from the 'release' branch." + exit 1 + fi + echo "Success!"