> ## Documentation Index
> Fetch the complete documentation index at: https://docs.acedata.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code GitHub Actions 配置指南

> Claude Code 集成指南 - Ace Data Cloud

## 1. 获取 API Key

打开 [Ace Data Cloud 应用列表](https://platform.acedata.cloud/console/applications)，进入可用的应用并复制 API Key。

![获取 Ace Data Cloud API Key](https://cdn.acedata.cloud/dvc3cg.jpg)

在目标 GitHub 仓库的 **Settings → Secrets and variables → Actions** 新建 Secret：

```text theme={null}
ACEDATACLOUD_API_KEY
```

## 2. 安装 GitHub App

安装 [Claude GitHub App](https://github.com/apps/claude) 并授权目标仓库。该官方 App 会请求固定的完整权限集；其中 Claude Code Action 实际使用 Contents、Issues 和 Pull requests 权限，GitHub 安装页不能只勾选这三项。若组织要求最小权限，请按官方文档创建自定义 GitHub App。

## 3. 添加 Workflow

创建 `.github/workflows/claude.yml`：

```yaml theme={null}
name: Claude Code

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

jobs:
  claude:
    if: contains(github.event.comment.body, '@claude')
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
      issues: write
      actions: read
      id-token: write
    env:
      ANTHROPIC_BASE_URL: https://api.acedata.cloud
      ANTHROPIC_CUSTOM_HEADERS: "Authorization: Bearer ${{ secrets.ACEDATACLOUD_API_KEY }}"
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 1
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: dummy-not-used
```

`claude-code-action` 需要非空的 `anthropic_api_key` 输入；这里的占位值不会用于平台鉴权。`ANTHROPIC_CUSTOM_HEADERS` 会覆盖为 Ace Data Cloud 所需的 Bearer Header，真实 Key 只来自 GitHub Secret。

## 4. 验证

提交 Workflow 后，在 Issue 或 PR 评论中发送：

```text theme={null}
@claude Reply only OK
```

成功时 Actions workflow 会完成，并在对应 Issue/PR 更新结果。如果 Action 提示缺少凭据，确认 `dummy-not-used` 仍存在；401 则检查 `ACEDATACLOUD_API_KEY` Secret。不要在日志中打印 Secret。可用 `claude_args` 按需设置 `--max-turns` 或选择当前可用模型，但接入模板不固定模型。

## 官方参考

* [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions)
* [claude-code-action](https://github.com/anthropics/claude-code-action)
