Skip to content

GitHub 集成

在 GitHub Issues 和 Pull Requests 中使用 OpenCode。

OpenCode 集成到你的 GitHub 工作流中。在评论中提及 /opencode/oc,OpenCode 将在你的 GitHub Actions runner 中执行任务。

功能

  • 分类 Issue:让 OpenCode 查看 Issue 并解释
  • 修复和实现:创建新分支、实现更改、提交 PR
  • 安全:在你的 GitHub runners 中运行

安装

bash
opencode github install

引导你完成 GitHub App 安装、工作流创建和密钥设置。

手动设置

  1. 安装 GitHub App
  2. 添加工作流文件 .github/workflows/opencode.yml
  3. 在仓库 设置 > Secrets and variables > Actions 中添加 API 密钥

配置选项

参数说明
model模型,格式 provider/model(必填)
agent使用的主 agent
share是否分享会话(公开仓库默认 true)
prompt自定义提示词覆盖默认行为
tokenGitHub 访问令牌

支持的事件

  • issue_comment:Issue/PR 评论中提及 /opencode
  • pull_request_review_comment:代码行评论
  • issues:Issue 创建或编辑(需 prompt)
  • pull_request:PR 操作(自动审查)
  • schedule:定时任务(需 prompt)
  • workflow_dispatch:手动触发

使用示例

  • 解释 Issue/opencode explain this issue
  • 修复 Issue/opencode fix this
  • 审查 PR:在 PR 评论中说明更改需求
  • 审查特定代码行:在 Files 标签页中直接评论代码行