支持使用 AI 进行四类操作,代码评审、PR 标题和描述的可读性检测、提交注释可读性检测、变更总结。
注意:结果仅供参考,不建议作为最终依据。
cnbcool/ai-review
type: 操作类型,默认为 code-review
code-review: 代码评审pr-info-readability-check: PR 标题和描述的可读性检测commit-message-readability-check: 提交注释可读性检测diff-summary: 变更总结message: type=commit-message-readability-check 时,可指定 message 参数,表示提交注释,
不指定默认取 CNB_COMMIT_MESSAGEpr_comment: true 或 false,默认为 true。是否将 pr 评论发表为 pull_request 行内评论(目前仅支持发送一条评论)。
type=code-review 时有效max_comments: 最大评论数,默认为 10,最多 10 条。
type=code-review 时有效prompt_output_file: 非必填,文件相对路径,如 ./prompt.txt。如传入则将 prompt 保存到文件中。result_output_file: 非必填,文件相对路径,如 ./result.txt。如传入则将 ai 输出结果保存到文件中。score_for_add_comment: 非必填,type=code-review 和 pr_comment 为 true 时,可指定此参数,表示评论分数阈值。低于这个分数的评审意见才发评论到 PR。pr-info-readability-check: 输出环境变量名 status,值为 yes 或 nocommit-message-readability-check: 输出环境变量名 status,值为 yes 或 nodiff-summary: 输出环境变量名 summary,表示变更总结内容默认会将 ai 评审意见发送评论到 pr,目前仅支持发送一条评论
main:
pull_request:
- stages:
- name: 代码评审
image: cnbcool/ai-review:latest
settings:
type: code-review
main:
pull_request:
- stages:
- name: 标题和描述的可读性检测
image: cnbcool/ai-review:latest
settings:
type: pr-info-readability-check
exports:
status: STATUS
- name: 标题和描述的可读性检测结果
script: |
case "${STATUS}" in
yes)
echo "✅ 标题和描述的可读性检测通过"
;;
no)
echo "⚠️ 标题和描述的可读性检测不通过"
exit 1
;;
esac
main:
push:
- stages:
- name: 提交注释的可读性检测
image: cnbcool/ai-review:latest
settings:
type: commit-message-readability-check
exports:
status: STATUS
- name: 提交注释的可读性检测结果
script: |
case "${STATUS}" in
yes)
echo "✅ 提交注释的可读性检测通过"
;;
no)
echo "⚠️ 提交注释的可读性检测不通过"
exit 1
;;
esac
main:
pull_request:
- stages:
- name: 变更总结
image: cnbcool/ai-review:latest
settings:
type: diff-summary
exports:
summary: SUMMARY
- name: 输出变更总结
script: echo $SUMMARY