From 76b8cc11680ae7f96fcd7203062eeea05319ba70 Mon Sep 17 00:00:00 2001 From: CaIon Date: Thu, 3 Jul 2025 13:33:50 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20pull=20request=20temp?= =?UTF-8?q?late=20and=20enforce=20branching=20strategy=20in=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pull_request_template.md | 19 +++++++++++++++++ .github/workflows/pr-target-branch-check.yml | 21 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md create mode 100644 .github/workflows/pr-target-branch-check.yml diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 00000000..4f6e41ac --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,19 @@ +### PR 类型 + +- [ ] Bug 修复 +- [ ] 新功能 +- [ ] 文档更新 +- [ ] 其他 + +### PR 是否包含破坏性更新? + +- [ ] 是 +- [ ] 否 + +### PR 描述 + +**请在下方详细描述您的 PR,包括目的、实现细节等。** + +### **重要提示** + +**所有 PR 都必须提交到 `alpha` 分支。请确保您的 PR 目标分支是 `alpha`。** diff --git a/.github/workflows/pr-target-branch-check.yml b/.github/workflows/pr-target-branch-check.yml new file mode 100644 index 00000000..e7bd4c81 --- /dev/null +++ b/.github/workflows/pr-target-branch-check.yml @@ -0,0 +1,21 @@ +name: Check PR Branching Strategy +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + check-branching-strategy: + runs-on: ubuntu-latest + steps: + - name: Enforce branching strategy + run: | + if [[ "${{ github.base_ref }}" == "main" ]]; then + if [[ "${{ github.head_ref }}" != "alpha" ]]; then + echo "Error: Pull requests to 'main' are only allowed from the 'alpha' branch." + exit 1 + fi + elif [[ "${{ github.base_ref }}" != "alpha" ]]; then + echo "Error: Pull requests must be targeted to the 'alpha' or 'main' branch." + exit 1 + fi + echo "Branching strategy check passed." \ No newline at end of file