Repository navigation
Conversation
- 新增 pr-contributor-trust 工作流与 .github/scripts/contributor-trust.ts - 四档标签:trusted-contributor / first-time-contributor / needs-human-review / bot-pr - 只分级不自动关闭;评论幂等;pull_request_target 下不 checkout PR 代码 - settings.yml 同步登记新增标签
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist(清单):
Closes #89
做了什么
给 PR 加一层「贡献者可信度」分级:PR 打开或更新时,按一组信号打分,打上四档标签之一,并留一条可自动更新的说明评论。
trusted-contributorfirst-time-contributorneeds-human-reviewbot-pr*[bot]评分信号:
.github/下的配置阈值集中在
contributor-trust.ts的打分段落,调数字即可,不需要动结构。为什么这样设计
1. 只分级,不自动关闭。
误杀一个真贡献者的代价,远高于多看一个低质 PR。社区真正的痛点是「维护者要在噪音里找人」,不是「bot 的 PR 必须消失」,所以这套只做分流,不做执法。
2. 评论幂等。
同一 PR 反复 push 只更新同一条评论(靠 HTML 注释标记定位),不会刷屏;
concurrency也按 PR 号分组,多次触发只跑最后一次。3. 安全:
pull_request_target但不 checkout PR 代码。只 checkout 默认分支,全程通过 GitHub API 读元数据,
permissions只给contents: read+issues/pull-requests: write。这是这类工作流最容易出事的地方——一旦在pull_request_target下 checkout 了 head,等于把仓库 secrets 交给任意 PR。4. 跟随仓库现有惯例。
脚本用 Deno + TypeScript 放在
.github/scripts/,action 锁到 commit SHA(与claim-issue-reward.yml一致),新增标签同时登记到.github/settings.yml。自测情况
本地已完成:
deno check .github/scripts/contributor-trust.ts通过;两个 YAML 均可正常解析。没有在真实 PR 上跑过——我没有这个仓库的写权限。合并前建议先在自己的 fork 上用
workflow_dispatch指定一个 PR 号跑一次,确认标签与评论符合预期,并验证重跑不会重复评论。后续可以再做
isBotUser()与share-reward.ts里的同名函数重复,可抽成.github/scripts/bot.ts共用(本次没有改动奖励链路,避免影响结算)first-time-contributor。要区分只能读 commit 里的Co-authored-by或 PR 模板自述,属于另一个话题