Files
BOJ/.gitea/workflows/ai-review.yml
T
2026-06-06 08:46:27 -07:00

40 lines
1.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: AI Code Review
# 触发条件:当向 main 分支发起 PR,或者 PR 有新代码提交时触发
on:
pull_request:
types: [opened, synchronize]
branches:
- main
jobs:
code-review:
runs-on: ubuntu-latest
steps:
# 1. 拉取代码
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # 必须设置为 0,获取完整提交历史,以便 AI 对比代码差异
# 2. 运行 AI 代码审查
- name: Run AI Code Review
uses: anc95/ChatGPT-CodeReview@main
env:
# Gitea 自带的 Token,用于让机器人能自动在你的 PR 下方发评论(系统自带,无需你手动配置)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 刚刚你在 Gitea "工作流 -> 密钥" 里配置的中转站 API Key
OPENAI_API_KEY: ${{ secrets.LLM_API_KEY }}
# 你的中转站 API 基础地址(务必保留结尾的 /v1)
OPENAI_API_ENDPOINT: "https://api.maxmodel.com/v1"
# 你想使用的模型名称(请填入你中转站支持的模型,比如 gpt-4o 或 deepseek-chat
MODEL: "gpt-4o"
# 设置 AI 评论的语言
LANGUAGE: "Chinese"
# 给 AI 的设定提示词,让它重点关注你关心的漏洞
SYSTEM_MESSAGE: "你是一个资深的 Python 架构师。请严格检查代码中的安全隐患(如硬编码密钥)、性能问题(如在 async 中使用同步阻塞 I/O)以及代码健壮性缺失,并提供具体的修复建议和代码示例。"