语速

OpenCode + Silicon Flow DeepSeek-V3.2 配置指南

概述

使用 Silicon Flow 的 DeepSeek-V3.2 模型进行 GitHub PR 自动代码审查。

配置步骤

1. 添加 GitHub Secret

在仓库 Settings → Secrets and variables → Actions 中添加:

  • Name: SILICONFLOW_API_KEY
  • Value: 你的 Silicon Flow API Key

2. 创建 opencode.json

在项目根目录创建 opencode.json

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "siliconflow": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Silicon Flow DeepSeek",
      "options": {
        "baseURL": "https://api.siliconflow.cn/v1"
      },
      "models": {
        "deepseek-ai/DeepSeek-V3.2": {
          "name": "DeepSeek-V3.2",
          "limit": {
            "context": 128000,
            "output": 8192
          }
        }
      }
    }
  }
}

3. 创建 GitHub Actions Workflow

创建 .github/workflows/opencode-review.yml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: OpenCode PR Review

on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]

jobs:
  review:
    name: AI Code Review
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest  # 或 self-hosted
    permissions:
      pull-requests: write
      issues: write
      contents: read
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          persist-credentials: true
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Run OpenCode Review
        uses: anomalyco/opencode/github@latest
        env:
          SILICONFLOW_API_KEY: ${{ secrets.SILICONFLOW_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          model: siliconflow/deepseek-ai/DeepSeek-V3.2
          use_github_token: true
          prompt: |
            Review this pull request (read-only mode, DO NOT modify any code):
            
            Please check:
            - Code quality issues
            - Potential bugs or logic errors
            - Code style consistency
            - Security concerns
            - Performance issues
            - Suggest improvements
            
            请用中文回复。不要修改任何代码,只提供审查意见。

关键配置说明

配置项说明
permissions.id-token: writeOIDC token 访问权限,必须添加
permissions.pull-requests: write允许发表 PR 评论
model: siliconflow/deepseek-ai/DeepSeek-V3.2格式: provider/model-id
use_github_token: true使用 GitHub Token 发表评论

验证

PR #3 测试通过: https://github.com/sun-praise/smart-device-modbus-testsuite/pull/3

Licensed under CC BY-NC-SA 4.0