fix(ci): 自动审查切换 DeepSeek V4 Pro #360
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
| name: DeepSeek PR Review | |
| # PR 打开 / reopen / 每次 push 新 commit(synchronize)时自动 review diff。 | |
| # 防邮件洪水靠三道闸而非「少触发」:① concurrency + cancel-in-progress 让同一 PR | |
| # 新 push 立刻取消上一轮;② review step 只维护**一条 sticky 总结评论** | |
| # (gh pr comment --edit-last 原地覆盖,GitHub 对编辑评论不发邮件,仅首条发一封); | |
| # ③ 不逐行贴 inline 评论。需对历史 commit 重审可去 Actions 页跑 workflow_dispatch。 | |
| # 非阻塞设计:即使 DeepSeek 出错(API 超时、token 过期等), | |
| # 本 workflow 不会阻止 PR 合并。review 评论是锦上添花,不是门禁。 | |
| # Auth: DeepSeek API key 存在 GitHub Actions Secret DEEPSEEK_API_KEY | |
| # | |
| # 保留原始 review prompt 和 sticky 评论编排,只替换底层模型。 | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: 手动指定 PR 编号(留空 = 用 workflow_dispatch 的当前分支) | |
| required: false | |
| # 同一 PR 新 push 立刻取消上一次 review,避免重复评论 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| review: | |
| name: DeepSeek · auto-review PR diff(非阻塞) | |
| runs-on: ubuntu-latest | |
| # 🔑 非阻塞关键:即使本 job 失败,也标记为成功,不卡 PR 合并 | |
| continue-on-error: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # 0 = 拉全历史,让 git log / git blame / git show 有上下文(架构评审需要) | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Fetch PR diff + metadata | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} | |
| run: | | |
| gh pr diff "$PR_NUMBER" --color never > /tmp/pr_diff.txt | |
| echo "diff_lines=$(wc -l < /tmp/pr_diff.txt)" >> $GITHUB_OUTPUT | |
| gh pr view "$PR_NUMBER" --json title,body,headRefName,baseRefName --jq '"\(.title) | \(.headRefName) → \(.baseRefName)"' > /tmp/pr_title.txt | |
| - name: DeepSeek V4 Pro · review | |
| id: review | |
| # 内层 step 也 continue-on-error,防止 Python 抛异常 | |
| continue-on-error: true | |
| env: | |
| DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }} | |
| run: python3 scripts/deepseek_review.py | |
| # 即使 DeepSeek 挂了,也记录一下方便排查 | |
| - name: Log review status | |
| if: always() | |
| run: | | |
| if [ "${{ steps.review.outcome }}" = "success" ]; then | |
| echo "DeepSeek review completed successfully" | |
| else | |
| echo "DeepSeek review skipped or failed (non-blocking) — outcome: ${{ steps.review.outcome }}" | |
| fi | |
| - name: Post/Update sticky comment | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} | |
| run: | | |
| BODY=$(cat /tmp/review_body.txt) | |
| MARKER="<!-- claude-review -->" | |
| SHA=$(git rev-parse --short HEAD) | |
| FULL_BODY="${MARKER}\nReview base: ${SHA}\n\n${BODY}" | |
| gh pr comment "$PR_NUMBER" --edit-last --create-if-none --body "$(echo -e "$FULL_BODY")" |