Skip to content

Commit cbc55a7

Browse files
author
yi-ge
committed
chore(cla): 改进 bot 识别与勾选匹配逻辑
- bot 跳过改用 pr.user.type === 'Bot',allowlist 保留作兜底; 此前只有 3 个特定 bot 在 allowlist,其他 bot(如 imgbot/pre-commit-ci)会被误判为 fail - CLA 勾选匹配兼容 [x] / [X];GitHub 二者都视为已勾选,原实现仅 includes('[x]') 会漏判
1 parent c632e94 commit cbc55a7

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

.github/workflows/cla.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
script: |
1717
const pr = context.payload.pull_request;
1818
19-
// Skip bot accounts
19+
// Skip bot accounts. pr.user.type === 'Bot' 覆盖所有机器人,allowlist 作兜底。
2020
const botList = ['dependabot[bot]', 'renovate[bot]', 'github-actions[bot]'];
21-
if (botList.includes(pr.user.login)) {
21+
if (pr.user.type === 'Bot' || botList.includes(pr.user.login)) {
2222
console.log(`Skipping CLA check for bot: ${pr.user.login}`);
2323
return;
2424
}
@@ -32,9 +32,10 @@ jobs:
3232
}
3333
3434
const body = pr.body || '';
35-
const claChecked =
36-
body.includes('[x] 我已阅读并同意 [贡献者许可协议 (CLA)]') ||
37-
body.includes('[x] I have read and agree to the [Contributor License Agreement (CLA)]');
35+
// GitHub 将 [x] 与 [X] 均视为已勾选,宽松匹配以避免大小写误判。
36+
const zhRe = /\[[xX]\][^\n]*我已阅读并同意[^\n]*贡献者许可协议/;
37+
const enRe = /\[[xX]\][^\n]*I have read and agree to the[^\n]*Contributor License Agreement/;
38+
const claChecked = zhRe.test(body) || enRe.test(body);
3839
3940
if (!claChecked) {
4041
core.setFailed(

0 commit comments

Comments
 (0)