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

# GitHub Secrets 配置

> 部署所需的所有 GitHub Secrets 详解

## 必填项

### CLOUDFLARE\_API\_TOKEN

1. 登录 [Cloudflare Dashboard](https://dash.cloudflare.com)
2. 右上角头像 → **My Profile** → **API Tokens**
3. **Create Token** → **Custom token**
4. 配置权限：

| 资源                   | 权限        |
| -------------------- | --------- |
| Account > Workers    | Edit      |
| Account > D1         | Edit      |
| Account > KV Storage | Edit      |
| Zone > Cache Purge   | Purge（可选） |

5. **Create Token** → 复制（仅显示一次）

<Warning>
  请妥善保管 Token，不要提交到 Git 仓库。
</Warning>

### CLOUDFLARE\_ACCOUNT\_ID

1. 登录 [Cloudflare Dashboard](https://dash.cloudflare.com)
2. 选择任意域名
3. 右侧栏 → **API** → **Account ID**
4. 复制 UUID 格式的 ID

### BLOG\_D1\_ID

```bash theme={null}
npx wrangler d1 create blog
```

输出示例：

```
✅ Successfully created DB 'blog'
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
```

复制 `database_id` 的值。

### BLOG\_KV\_ID

```bash theme={null}
npx wrangler kv namespace create BLOG
```

输出示例：

```
✅ Successfully created KV namespace 'BLOG'
id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```

复制 `id` 的值。

## 推荐项

### BLOG\_ADMIN\_SETUP\_KEY

自行生成随机字符串：

```bash theme={null}
# macOS/Linux
openssl rand -hex 32
```

<Info>
  此密钥仅在首次设置管理员密码时使用，设置完成后即失效。不配置时系统自动生成随机默认密码。
</Info>

### SITE\_URL

博客对外地址，如 `https://blog.example.com`（不带末尾斜杠）。

配置后收紧 CORS 策略，仅允许本站来源。

### CF\_ZONE\_ID

自定义域名的 Zone ID。配置后每次发布自动清除 CDN 缓存。

## 配置步骤

1. 进入 GitHub 仓库 → **Settings**
2. **Secrets and variables** → **Actions**
3. **New repository secret** → 填入 Name 和 Value
4. 重复添加所有 Secret
