GitHub Integration
通过在评论中提及 @cline,使用 GitHub Actions 中的 Cline CLI 自动响应 GitHub 问题。
使用 AI 自动化 GitHub 问题分析。在任何问题评论中提及 @cline 即可触发自主调查,包括读取文件、分析代码并提供可操作的见解——所有这些都在 GitHub Actions 中自动运行。
**刚开始使用 Cline CLI?** 此示例假设您了解 Cline CLI 的基础知识并已完成[安装指南](https://docs.cline.bot/cline-cli/installation)。如果您是 Cline CLI 的新手,我们建议先从 [GitHub RCA 示例](./github-issue-rca)开始,因为它更简单,可以帮助您在设置 GitHub Actions 之前理解基础知识。
工作流程
在任何问题评论中提及 @cline 即可触发 Cline:

Cline 的自动分析会以新评论的形式出现,见解来自您的实际代码库:

整个调查过程都在 GitHub Actions 中自主运行——从文件探索到发布结果。
让我们配置您的仓库。
前置条件
在开始之前,您需要:
Cline CLI 知识 - 已完成安装指南并了解基本用法
GitHub 仓库 - 具有配置 Actions 和机密的管理员访问权限
GitHub Actions 熟悉度 - 基本了解工作流程和 CI/CD
API 提供商账户 - OpenRouter、Anthropic 或类似账户,具有 API 密钥
设置
1. 复制工作流程文件
将此示例中的工作流程文件复制到您的仓库。工作流程文件必须放置在仓库根目录的 .github/workflows/ 目录中,以便 GitHub Actions 检测并运行它。在本例中,我们将其命名为 cline-responder.yml。
或者,您可以直接将完整的工作流程文件复制到 .github/workflows/cline-responder.yml:
```yaml name: Cline Issue Assistant
on: issue_comment: types: [created, edited]
permissions: issues: write
jobs: respond: runs-on: ubuntu-latest environment: cline-actions steps: - name: Check for @cline mention id: detect uses: actions/github-script@v7 with: script: | const body = context.payload.comment?.body || ""; const isPR = !!context.payload.issue?.pull_request; const hit = body.toLowerCase().includes("@cline"); core.setOutput("hit", (!isPR && hit) ? "true" : "false"); core.setOutput("issue_number", String(context.payload.issue?.number || "")); core.setOutput("issue_url", context.payload.issue?.html_url || ""); core.setOutput("comment_body", body);
示例: 如果您的仓库是 github.com/acme/myproject,请设置:
这告诉工作流程在步骤 3 中提交脚本后,从您的仓库下载分析脚本的位置。
工作流程将查找新的或更新的问题,检查 @cline 提及,然后 启动 Cline CLI 实例来深入调查问题,作为问题的回复提供反馈。
2. 配置 API 密钥
将 AI 提供商 API 密钥添加为仓库机密:
转到您的 GitHub 仓库
导航到 Settings → Environment 并添加新环境。

确保将其命名为"cline-actions",以便与
cline-responder.yml文件顶部的environment值匹配。点击 New repository secret
为
OPENROUTER_API_KEY添加一个机密,值为来自 openrouter.com 的 API 密钥。
验证您的机密已配置:

现在您准备好在 GitHub Action 中为 Cline 提供所需的凭据了。
3. 添加分析脚本
将 github-issue-rca 示例中的分析脚本添加到您的仓库。首先,您需要在仓库根目录中创建一个 git-scripts 目录,脚本将位于该目录中。 选择以下选项之一:
选项 A:直接下载(推荐)
选项 B:手动复制粘贴
手动创建目录和文件,然后粘贴脚本内容:
```bash #!/bin/bash # 使用 Cline CLI 分析 GitHub 问题
if [ -z "$1" ]; then echo "Usage: $0 [prompt] [address]" echo "Example: $0 https://github.com/owner/repo/issues/123" echo "Example: $0 https://github.com/owner/repo/issues/123 'What is the root cause of this issue?'" echo "Example: $0 https://github.com/owner/repo/issues/123 'What is the root cause of this issue?' 127.0.0.1:46529" exit 1 fi
收集参数
ISSUE_URL="$1" PROMPT="${2:-What is the root cause of this issue?}" if [ -n "$3" ]; then ADDRESS="--address $3" fi
向 Cline 请求分析,仅显示摘要
cline -y "$PROMPT: $ISSUE_URL" --mode act $ADDRESS -F json | sed -n '/^{/,$p' | jq -r 'select(.say == "completion_result") | .text' | sed 's/\n/\n/g'
此分析脚本调用 Cline 对 GitHub 问题执行提示词, 总结输出以填充对问题的回复。
4. 提交和推送
使用方法
设置完成后,只需在任何问题评论中提及 @cline:
GitHub Actions 将:
检测
@cline提及启动 Cline CLI 实例
下载分析脚本
使用 act 模式和 yolo(完全自主)分析问题
将 Cline 的分析作为新评论发布
注意:工作流程仅在问题评论上触发,而不在拉取请求 评论上触发。
工作原理
工作流程(cline-responder.yml):
触发于问题评论(创建或编辑)
检测
@cline提及(不区分大小写)安装使用 npm 全局安装 Cline CLI
创建使用
cline instance new创建 Cline 实例配置使用
cline config set open-router-api-key=... --address ...配置身份验证下载从
github-issue-rca示例下载可重用的analyze-issue.sh脚本运行使用实例地址运行分析
发布将分析结果作为评论发布
相关示例
github-issue-rca:为此集成提供支持的可重用脚本
Last updated