# Gitea Actions Runner 配置指南

## 概述

Gitea Actions 是 Gitea 的 CI/CD 系统，与 GitHub Actions 兼容。

## 配置步骤

### 1. 启用 Gitea Actions

编辑 Gitea 配置文件 (`/etc/gitea/app.ini` 或 `~/.gitea/conf/app.ini`):

```ini
[actions]
ENABLED = true
DEFAULT_ACTIONS_URL = github
```

重启 Gitea:
```bash
sudo systemctl restart gitea
```

### 2. 安装 Runner

#### macOS 安装

```bash
# 下载 Runner
mkdir -p ~/gitea-runner
cd ~/gitea-runner
curl -L https://github.com/actions/runner/releases/latest/download/actions-runner-darwin-x64-2.311.0.tar.gz -o runner.tar.gz
tar xzf runner.tar.gz

# 配置 Runner
./config.sh --url http://192.168.120.110:4000/damai/readflow \
            --token <TOKEN_FROM_GITEA> \
            --name macos-runner \
            --runnergroup default

# 启动 Runner
./run.sh
```

#### Linux 安装

```bash
# 下载 Runner
mkdir -p ~/gitea-runner
cd ~/gitea-runner
curl -L https://github.com/actions/runner/releases/latest/download/actions-runner-linux-x64-2.311.0.tar.gz -o runner.tar.gz
tar xzf runner.tar.gz

# 配置 Runner
./config.sh --url http://192.168.120.110:4000/damai/readflow \
            --token <TOKEN_FROM_GITEA> \
            --name linux-runner \
            --runnergroup default

# 启动 Runner
./run.sh
```

### 3. 获取 Runner Token

1. 访问 Gitea 仓库：http://192.168.120.110:4000/damai/readflow
2. 进入 Settings → Actions
3. 点击 "Add runner"
4. 复制 Token

### 4. 验证 Runner

访问 Gitea 仓库的 Actions 页面，应该能看到注册的 Runner。

### 5. 触发编译

推送标签触发编译:

```bash
cd /Users/rong/.openclaw/workspace/readflow
git tag -a v0.2.1 -m "Release v0.2.1"
git push origin v0.2.1
```

---

## 工作流文件

工作流文件位于：`.gitea/workflows/release.yml`

支持的平台:
- ✅ Windows (x86_64-pc-windows-gnu)
- ✅ Linux (x86_64-unknown-linux-gnu)
- ✅ macOS (x86_64-apple-darwin)

---

## 故障排除

### Runner 无法连接

检查 Gitea 配置:
```ini
[actions]
ENABLED = true
DEFAULT_ACTIONS_URL = github
```

### 编译失败

检查 Runner 是否安装了必要的依赖:
```bash
# macOS
brew install rust mingw-w64

# Linux
sudo apt-get install rustc mingw-w64
```

### 查看日志

访问 Gitea 仓库的 Actions 页面查看编译日志。

---

## 快速开始

### 方案 1: 使用 Docker Runner (推荐)

```bash
docker run -d \
  -e GITEA_INSTANCE_URL=http://192.168.120.110:4000 \
  -e GITEA_RUNNER_REGISTRATION_TOKEN=<TOKEN> \
  -e GITEA_RUNNER_NAME=docker-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  ghcr.io/gitea/act_runner:latest
```

### 方案 2: 本地安装 Runner

参考上面的安装步骤。

---

## 参考资料

- Gitea Actions 文档：https://docs.gitea.io/usage/actions/
- Runner 下载：https://github.com/actions/runner/releases
- Workflows 语法：https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
