From bc3b5e58a417d145f355b76160d4d1201ce4132e Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Mon, 16 Mar 2026 02:44:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20pr-checklist-check.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-checklist-check.yml | 42 ++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-checklist-check.yml b/.github/workflows/pr-checklist-check.yml index f93eac126..26b145a05 100644 --- a/.github/workflows/pr-checklist-check.yml +++ b/.github/workflows/pr-checklist-check.yml @@ -23,7 +23,7 @@ jobs: const bad = regex.test(body); core.setOutput("bad", bad); - - name: Close PR + - name: Close PR if checklist violated if: steps.check.outputs.bad == 'true' uses: actions/github-script@v7 with: @@ -42,4 +42,42 @@ jobs: repo: context.repo.repo, pull_number: pr.number, state: "closed" - }); \ No newline at end of file + }); + + - name: Check target branch + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + const base = pr.base.ref; + + if (base !== "dev") { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: `⚠️ 当前 PR 的 **目标分支是 \`${base}\`**。 + +建议将 PR 合并到 **\`dev\` 分支(开发分支)**,这样通常可以 **更快被合并**。 + +除非你的 PR **非常紧急**,否则请不要直接提交到 **\`master\` 分支**。` + }); + } + + - name: Check source branch + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + const head = pr.head.ref; + + if (head !== "dev") { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: `💡 当前 PR 的 **源分支是 \`${head}\`**。 + +建议 **基于 \`dev\` 分支进行开发**,并及时从 \`dev\` 拉取更新,这样可以显著减少 **合并冲突的可能性**。` + }); + } \ No newline at end of file