Refine PR checklist validation and closure message
Updated the checklist validation script and modified the comment for PR closure.
This commit is contained in:
@@ -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',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user