Files
opencode/command/gitea-list-runners.md

95 lines
2.8 KiB
Markdown

---
description: List all global runners on Gitea server
---
List all global runners registered on the Gitea server.
## 工作目录
**macOS / Linux:**
```
~/.config/gitea/
```
**Windows:**
```
%USERPROFILE%\.config\gitea\
```
Please perform the following:
1. **Read Gitea configuration:**
- Read from config file:
- macOS/Linux: `~/.config/gitea/config.env`
- Windows: `%USERPROFILE%\.config\gitea\config.env`
- Extract:
- `GITEA_URL`: Gitea server URL
- `GITEA_TOKEN`: API token (admin permission required)
- If config not found: prompt user to run `/gitea-reset` first
2. **Call Gitea API to list runners:**
```bash
curl -s -H "Authorization: token <token>" \
"<server>/api/v1/admin/actions/runners"
```
3. **Parse JSON response and extract information:**
- Response structure:
```json
{
"runners": [...],
"total_count": 1
}
```
- Use `jq` to parse JSON
- For each runner in `runners` array:
- `id`: Runner ID
- `name`: Runner name
- `status`: Runner status ("online"/"offline")
- `busy`: Whether runner is currently busy (true/false)
- `ephemeral`: Whether runner is ephemeral (true/false)
- `labels`: Array of label objects with `name` and `type`
4. **Determine runner status:**
- 🟢 在线 - `status: "online"`
- 🔴 离线 - `status: "offline"`
- ⚠️ 未知 - Unable to determine
5. **Filter global runners:**
- The API endpoint `/api/v1/admin/actions/runners` returns all global runners
- These are runners registered at the instance level (not org or repo specific)
6. **Display summary in Chinese:**
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Gitea 全局 Runners
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
服务器: [server_url]
总计: N 个全局 runner
[runner-name]
状态: 🟢/🔴 [在线/离线]
ID: [id]
忙碌: 是/否
临时: 是/否
标签: [comma-separated labels]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
管理命令
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
查看配置: /gitea-config
创建 runner: /gitea-create-runner
删除 runner: /gitea-delete-runner
```
**Notes:**
- Requires admin API token to list runners
- **Correct API endpoint**: `/api/v1/admin/actions/runners` (not `/api/v1/admin/runners`)
- Only shows global runners (instance-level runners)
- Uses `jq` for JSON parsing
- Response includes: `id`, `name`, `status`, `busy`, `ephemeral`, `labels`
- If API call fails, show error message and suggest checking token permissions
- Tested with Gitea version 1.25.3