From 56619c74a2aad1b321ca7b00e5f2f113f8fc716d Mon Sep 17 00:00:00 2001 From: Eric Forte Date: Thu, 26 Mar 2026 22:37:39 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20add=20CI=20guard=20=E2=80=94=20only=20?= =?UTF-8?q?development=20can=20merge=20into=20main?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fails any PR to main that doesn't originate from the development branch. Must be paired with a required status check on main branch protection. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/protect-main.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/protect-main.yml diff --git a/.github/workflows/protect-main.yml b/.github/workflows/protect-main.yml new file mode 100644 index 0000000..a90fd39 --- /dev/null +++ b/.github/workflows/protect-main.yml @@ -0,0 +1,30 @@ +name: Protect main branch + +on: + pull_request: + branches: + - main + +jobs: + require-development-source: + name: Source must be development + runs-on: ubuntu-latest + steps: + - name: Check PR source branch + run: | + echo "PR source branch: ${{ github.head_ref }}" + if [ "${{ github.head_ref }}" != "development" ]; then + echo "" + echo "❌ Direct PRs to main are not allowed." + echo "" + echo " Only the 'development' branch can be merged into 'main'." + echo "" + echo " Correct workflow:" + echo " 1. Branch off development" + echo " 2. Open a PR to development" + echo " 3. Merge into development" + echo " 4. Open a PR from development → main for release" + echo "" + exit 1 + fi + echo "✅ Source is 'development' — merge allowed."