From 00f6ea3d88d40ebaf04ff3fcc99eab9fa155ec09 Mon Sep 17 00:00:00 2001 From: Simba Zhang Date: Fri, 6 Mar 2026 14:07:08 -0800 Subject: [PATCH] =?UTF-8?q?ci:=20add=20PR=20target=20check=20workflow=20?= =?UTF-8?q?=E2=80=94=20enforce=20develop-only=20PRs=20to=20master?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-target-check.yml | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/pr-target-check.yml diff --git a/.github/workflows/pr-target-check.yml b/.github/workflows/pr-target-check.yml new file mode 100644 index 00000000..cb7ee50f --- /dev/null +++ b/.github/workflows/pr-target-check.yml @@ -0,0 +1,29 @@ +name: PR Target Check + +on: + pull_request: + types: [opened, reopened, edited, synchronize] + +jobs: + check-target: + runs-on: ubuntu-latest + steps: + - name: Enforce branch strategy + run: | + BASE="${{ github.event.pull_request.base.ref }}" + HEAD="${{ github.event.pull_request.head.ref }}" + + echo "PR: $HEAD → $BASE" + + if [ "$BASE" = "master" ] && [ "$HEAD" != "develop" ]; then + echo "❌ Only the 'develop' branch can open PRs to 'master'." + echo " Please target 'develop' instead." + exit 1 + fi + + if [ "$BASE" = "develop" ] && [ "$HEAD" = "master" ]; then + echo "❌ Do not merge 'master' back into 'develop'." + exit 1 + fi + + echo "✅ PR target is valid: $HEAD → $BASE"