From a3fa8a5a7ccd03f01a5ef5c51fc93e324d9cedc4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 17:28:39 +0000 Subject: [PATCH 1/5] Initial plan From dd89a4b33418a6b86e28e3f859ca63be60d69973 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 17:30:29 +0000 Subject: [PATCH 2/5] feat: add PR checklist enforcement workflow Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com> --- .github/workflows/pr-checklist-check.yml | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/pr-checklist-check.yml diff --git a/.github/workflows/pr-checklist-check.yml b/.github/workflows/pr-checklist-check.yml new file mode 100644 index 000000000..ce57c8d7d --- /dev/null +++ b/.github/workflows/pr-checklist-check.yml @@ -0,0 +1,69 @@ +# This workflow checks whether the PR author checked the "I did NOT read" item +# in the PR checklist. If so, it posts a reminder comment and closes the PR. +name: PR Checklist Check + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +jobs: + check-checklist: + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - name: Check if the "did not read" item is checked + id: check + uses: actions/github-script@v7 + with: + script: | + const body = context.payload.pull_request.body || ''; + // Match the last checklist item being checked (- [x] ⚠️ 我**没有**认真阅读) + const violationPattern = /- \[x\] ⚠️ 我\*\*没有\*\*认真阅读以上内容,直接提交。/; + return violationPattern.test(body); + result-encoding: string + + - name: Comment and close PR if checklist violated + if: steps.check.outputs.result == 'true' + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.payload.pull_request.number; + const author = context.payload.pull_request.user.login; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body: `👋 @${author} + + 您的 PR 未通过检查清单校验 —— 检测到您勾选了「我**没有**认真阅读以上内容,直接提交」。 + + 请按照以下规则重新提交 PR: + + 1. 请仔细阅读 PR 模板中的所有说明。 + 2. 本次开发请**基于 \`dev\` 分支**进行,并将 PR 目标分支设置为**开发分支(\`dev\`)**(除非极其紧急的情况才允许合并到主分支)。 + 3. 完成上述检查后,请重新发起 PR。 + + 本 PR 已自动关闭,请按规范重新拉起。感谢您的贡献!🙏 + + --- + + Your PR failed the checklist validation — the item "I **did not** read the above carefully before submitting" was checked. + + Please follow these rules and reopen a new PR: + + 1. Read all the instructions in the PR template carefully. + 2. Make sure your development is **based on the \`dev\` branch**, and set the PR target branch to the **development branch (\`dev\`)** (only merge to main if extremely urgent). + 3. Once you have reviewed everything, please open a new PR. + + This PR has been automatically closed. Please reopen a correct one. Thank you for your contribution! 🙏`, + }); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + state: 'closed', + }); From 2bbca887cea1f7a08172adfd92ac9260d32fcd1f Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Mon, 16 Mar 2026 01:46:07 +0800 Subject: [PATCH 3/5] Refine PR checklist validation and closure message Updated the checklist validation script and modified the comment for PR closure. --- .github/workflows/pr-checklist-check.yml | 40 +++++------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/.github/workflows/pr-checklist-check.yml b/.github/workflows/pr-checklist-check.yml index ce57c8d7d..2f5a8eab8 100644 --- a/.github/workflows/pr-checklist-check.yml +++ b/.github/workflows/pr-checklist-check.yml @@ -13,15 +13,18 @@ jobs: pull-requests: write steps: - - name: Check if the "did not read" item is checked + - name: Check if user checked "我没有认真阅读" id: check uses: actions/github-script@v7 with: script: | const body = context.payload.pull_request.body || ''; - // Match the last checklist item being checked (- [x] ⚠️ 我**没有**认真阅读) - const violationPattern = /- \[x\] ⚠️ 我\*\*没有\*\*认真阅读以上内容,直接提交。/; - return violationPattern.test(body); + + // 只匹配:整行是 - [x] + 包含“没有认真阅读” + const regex = /-\s*\[\s*x\s*\].*我\*\*没有\*\*认真阅读以上内容/im; + const isBad = regex.test(body); + + return isBad; result-encoding: string - name: Comment and close PR if checklist violated @@ -38,32 +41,3 @@ jobs: issue_number: prNumber, body: `👋 @${author} - 您的 PR 未通过检查清单校验 —— 检测到您勾选了「我**没有**认真阅读以上内容,直接提交」。 - - 请按照以下规则重新提交 PR: - - 1. 请仔细阅读 PR 模板中的所有说明。 - 2. 本次开发请**基于 \`dev\` 分支**进行,并将 PR 目标分支设置为**开发分支(\`dev\`)**(除非极其紧急的情况才允许合并到主分支)。 - 3. 完成上述检查后,请重新发起 PR。 - - 本 PR 已自动关闭,请按规范重新拉起。感谢您的贡献!🙏 - - --- - - Your PR failed the checklist validation — the item "I **did not** read the above carefully before submitting" was checked. - - Please follow these rules and reopen a new PR: - - 1. Read all the instructions in the PR template carefully. - 2. Make sure your development is **based on the \`dev\` branch**, and set the PR target branch to the **development branch (\`dev\`)** (only merge to main if extremely urgent). - 3. Once you have reviewed everything, please open a new PR. - - This PR has been automatically closed. Please reopen a correct one. Thank you for your contribution! 🙏`, - }); - - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: prNumber, - state: 'closed', - }); From 11c840953aa11001d0d0745dcf740f4291cf8605 Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Mon, 16 Mar 2026 01:49:49 +0800 Subject: [PATCH 4/5] =?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 | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/pr-checklist-check.yml b/.github/workflows/pr-checklist-check.yml index 2f5a8eab8..78342f063 100644 --- a/.github/workflows/pr-checklist-check.yml +++ b/.github/workflows/pr-checklist-check.yml @@ -41,3 +41,32 @@ jobs: issue_number: prNumber, body: `👋 @${author} +您的 PR 未通过检查清单校验 —— 检测到您勾选了「我**没有**认真阅读以上内容,直接提交」。 + +请按照以下规则重新提交 PR: + +1. 请仔细阅读 PR 模板中的所有说明。 +2. 本次开发请**基于 \`dev\` 分支**进行,并将 PR 目标分支设置为**开发分支(\`dev\`)**(除非极其紧急的情况才允许合并到主分支)。 +3. 完成上述检查后,请重新发起 PR。 + +本 PR 已自动关闭,请按规范重新拉起。感谢您的贡献!🙏 + +--- + +Your PR failed the checklist validation — the item "I **did not** read the above carefully before submitting" was checked. + +Please follow these rules and reopen a new PR: + +1. Read all the instructions in the PR template carefully. +2. Make sure your development is **based on the \`dev\` branch**, and set the PR target branch to the **development branch (\`dev\`)** (only merge to main if extremely urgent). +3. Once you have reviewed everything, please open a new PR. + +This PR has been automatically closed. Please reopen a correct one. Thank you for your contribution! 🙏` + }); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + state: 'closed' + }); From 6b3868b4be24399f2e4125365a27055593aca1a3 Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Mon, 16 Mar 2026 02:11:15 +0800 Subject: [PATCH 5/5] Update pr-checklist-check.yml --- .github/workflows/pr-checklist-check.yml | 36 +++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pr-checklist-check.yml b/.github/workflows/pr-checklist-check.yml index 78342f063..6346ef4e0 100644 --- a/.github/workflows/pr-checklist-check.yml +++ b/.github/workflows/pr-checklist-check.yml @@ -3,7 +3,7 @@ name: PR Checklist Check on: - pull_request: + pull_request_target: types: [opened, edited, reopened, synchronize] jobs: @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest permissions: pull-requests: write + issues: write steps: - name: Check if user checked "我没有认真阅读" @@ -20,8 +21,8 @@ jobs: script: | const body = context.payload.pull_request.body || ''; - // 只匹配:整行是 - [x] + 包含“没有认真阅读” - const regex = /-\s*\[\s*x\s*\].*我\*\*没有\*\*认真阅读以上内容/im; + // 精确匹配完整的 checklist 项:- [x] 或 - [X] 后跟完整句子,忽略大小写和多余空格 + const regex = /-+\s*\[\s*[xX]\s*\]\s*⚠️\s*我\*\*没有\*\*认真阅读以上内容,直接提交。/im; const isBad = regex.test(body); return isBad; @@ -39,29 +40,30 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, - body: `👋 @${author} + body: | + 👋 @${author} -您的 PR 未通过检查清单校验 —— 检测到您勾选了「我**没有**认真阅读以上内容,直接提交」。 + 您的 PR 未通过检查清单校验 —— 检测到您勾选了「我**没有**认真阅读以上内容,直接提交」。 -请按照以下规则重新提交 PR: + 请按照以下规则重新提交 PR: -1. 请仔细阅读 PR 模板中的所有说明。 -2. 本次开发请**基于 \`dev\` 分支**进行,并将 PR 目标分支设置为**开发分支(\`dev\`)**(除非极其紧急的情况才允许合并到主分支)。 -3. 完成上述检查后,请重新发起 PR。 + 1. 请仔细阅读 PR 模板中的所有说明。 + 2. 本次开发请**基于 \`dev\` 分支**进行,并将 PR 目标分支设置为**开发分支(\`dev\`)**(除非极其紧急的情况才允许合并到主分支)。 + 3. 完成上述检查后,请重新发起 PR。 -本 PR 已自动关闭,请按规范重新拉起。感谢您的贡献!🙏 + 本 PR 已自动关闭,请按规范重新拉起。感谢您的贡献!🙏 ---- + --- -Your PR failed the checklist validation — the item "I **did not** read the above carefully before submitting" was checked. + Your PR failed the checklist validation — the item "I **did not** read the above carefully before submitting" was checked. -Please follow these rules and reopen a new PR: + Please follow these rules and reopen a new PR: -1. Read all the instructions in the PR template carefully. -2. Make sure your development is **based on the \`dev\` branch**, and set the PR target branch to the **development branch (\`dev\`)** (only merge to main if extremely urgent). -3. Once you have reviewed everything, please open a new PR. + 1. Read all the instructions in the PR template carefully. + 2. Make sure your development is **based on the \`dev\` branch**, and set the PR target branch to the **development branch (\`dev\`)** (only merge to main if extremely urgent). + 3. Once you have reviewed everything, please open a new PR. -This PR has been automatically closed. Please reopen a correct one. Thank you for your contribution! 🙏` + This PR has been automatically closed. Please reopen a correct one. Thank you for your contribution! 🙏 }); await github.rest.pulls.update({