forked from Gitlink/gitlink-cli
200 lines
5.7 KiB
Markdown
200 lines
5.7 KiB
Markdown
# Workflow: Multi-Repo Collaboration(多仓库协同)
|
||
|
||
> **前置条件:** 先阅读 [`../../gitlink-shared/SKILL.md`](../../../gitlink-shared/SKILL.md) 了解认证、全局参数和安全规则。
|
||
> **AI Agent 工作流**:此工作流专为 AI Agent 设计,用于跨仓库协同管理。
|
||
|
||
AI Agent 自动汇总组织下所有仓库的 Issue、PR、Release 状态,生成可视化 Dashboard,支持协同发版。
|
||
|
||
## 工作流概述
|
||
|
||
Multi-Repo Collaboration 工作流通过遍历组织下的所有仓库,收集各仓库的 Issue、PR、Release 数据,生成统一的状态 Dashboard,并支持跨仓库协同发版。
|
||
|
||
## 适用场景
|
||
|
||
- **状态总览**:查看组织下所有仓库的健康状态
|
||
- **跨仓库追踪**:追踪跨仓库的 Issue 和 PR
|
||
- **协同发版**:多个仓库同时发布同一版本
|
||
- **团队协调**:协调团队在多个项目间的工作
|
||
|
||
## 触发词
|
||
|
||
- "多仓库" / "multi repo"
|
||
- "协同" / "collaboration"
|
||
- "dashboard" / "看板"
|
||
- "组织仓库" / "org repos"
|
||
|
||
## 参数
|
||
|
||
| 参数 | 必填 | 说明 |
|
||
|------|------|------|
|
||
| `--org` | 是 | 组织名称 |
|
||
| `--repos` | 否 | 指定仓库列表(逗号分隔),默认遍历所有仓库 |
|
||
| `--release` | 否 | 协同发版的版本号 |
|
||
| `--output` | 否 | Dashboard 输出文件(默认 dashboard.html) |
|
||
|
||
## 工作流步骤
|
||
|
||
### 步骤 1:列出组织仓库
|
||
|
||
```bash
|
||
# 获取组织下所有仓库
|
||
gitlink-cli repo +list --user {ORG} --limit 100 --format json
|
||
```
|
||
|
||
提取仓库列表:`.data.projects[]` 或 `.data[]`,字段:`.name` 或 `.identifier`
|
||
|
||
### 步骤 2:收集各仓库数据
|
||
|
||
遍历每个仓库,收集 Issue、PR、Release 数据:
|
||
|
||
```bash
|
||
# Open Issues
|
||
gitlink-cli issue +list --owner {ORG} --repo {REPO} --state open --limit 50 --format json
|
||
|
||
# Closed Issues
|
||
gitlink-cli issue +list --owner {ORG} --repo {REPO} --state closed --limit 50 --format json
|
||
|
||
# Open PRs
|
||
gitlink-cli pr +list --owner {ORG} --repo {REPO} --state open --limit 50 --format json
|
||
|
||
# Merged PRs
|
||
gitlink-cli pr +list --owner {ORG} --repo {REPO} --state merged --limit 50 --format json
|
||
|
||
# Latest Release
|
||
gitlink-cli release +list --owner {ORG} --repo {REPO} --limit 1 --format json
|
||
```
|
||
|
||
### 步骤 3:生成 Dashboard
|
||
|
||
Dashboard 包含:
|
||
- **汇总卡片**:总仓库数、Open Issues、Open PRs、总活动量
|
||
- **仓库状态表**:每个仓库的 Issue/PR/Release 状态和健康度
|
||
|
||
**健康度判断**:
|
||
- Open Issues <= 10 → Healthy(绿色)
|
||
- Open Issues 11-20 → Moderate(橙色)
|
||
- Open Issues > 20 → Needs Attention(红色)
|
||
|
||
### 步骤 4:协同发版(可选)
|
||
|
||
如果指定了 `--release` 参数,为所有仓库创建 Release:
|
||
|
||
```bash
|
||
gitlink-cli release +create \
|
||
--owner {ORG} \
|
||
--repo {REPO} \
|
||
--tag {VERSION} \
|
||
--name "Release {VERSION}" \
|
||
--body "Coordinated release {VERSION} for {REPO}"
|
||
```
|
||
|
||
## 数据提取
|
||
|
||
### Issue 数量
|
||
|
||
```bash
|
||
# Open Issues 数量
|
||
OPEN_COUNT=$(gitlink-cli issue +list --owner {ORG} --repo {REPO} --state open --limit 50 --format json | jq '.data.issues | length')
|
||
|
||
# Closed Issues 数量
|
||
CLOSED_COUNT=$(gitlink-cli issue +list --owner {ORG} --repo {REPO} --state closed --limit 50 --format json | jq '.data.issues | length')
|
||
```
|
||
|
||
### PR 数量
|
||
|
||
```bash
|
||
# Open PRs 数量
|
||
OPEN_PRS=$(gitlink-cli pr +list --owner {ORG} --repo {REPO} --state open --limit 50 --format json | jq '.data.issues | length')
|
||
|
||
# Merged PRs 数量
|
||
MERGED_PRS=$(gitlink-cli pr +list --owner {ORG} --repo {REPO} --state merged --limit 50 --format json | jq '.data.issues | length')
|
||
```
|
||
|
||
### Release 状态
|
||
|
||
```bash
|
||
# 最新 Release
|
||
LATEST_RELEASE=$(gitlink-cli release +list --owner {ORG} --repo {REPO} --limit 1 --format json | jq -r '.data.releases[0].tag_name // "none"')
|
||
```
|
||
|
||
## 输出示例
|
||
|
||
### Dashboard HTML
|
||
|
||
```html
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<title>Multi-Repo Collaboration Dashboard</title>
|
||
<style>
|
||
/* 样式定义 */
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>Multi-Repo Collaboration Dashboard</h1>
|
||
<div class="summary">
|
||
<div class="card">Total Repos: 10</div>
|
||
<div class="card">Open Issues: 45</div>
|
||
<div class="card">Open PRs: 12</div>
|
||
<div class="card">Total Activity: 156</div>
|
||
</div>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Repository</th>
|
||
<th>Open Issues</th>
|
||
<th>Closed Issues</th>
|
||
<th>Open PRs</th>
|
||
<th>Merged PRs</th>
|
||
<th>Latest Release</th>
|
||
<th>Health</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<!-- 仓库状态行 -->
|
||
</tbody>
|
||
</table>
|
||
</body>
|
||
</html>
|
||
```
|
||
|
||
### 控制台输出
|
||
|
||
```
|
||
====== Multi-Repo Collaboration Dashboard ======
|
||
|
||
[STEP] Fetching repositories for org: myorg...
|
||
[ OK] Found 10 repositories
|
||
|
||
[STEP] Processing repo1...
|
||
[ OK] repo1 : Issues(open:5 closed:12) PRs(open:2 merged:8) Release:v1.2.0
|
||
|
||
[STEP] Processing repo2...
|
||
[ OK] repo2 : Issues(open:15 closed:20) PRs(open:5 merged:15) Release:v2.0.0
|
||
|
||
====== Generating Dashboard ======
|
||
[ OK] Dashboard saved to: dashboard.html
|
||
|
||
====== Multi-Repo Dashboard Complete ======
|
||
|
||
Repos processed: 10
|
||
Total issues: 156 (open: 45)
|
||
Total PRs: 89 (open: 12)
|
||
Dashboard: dashboard.html
|
||
```
|
||
|
||
## 注意事项
|
||
|
||
- 大量仓库时注意 API 限流,建议添加延时
|
||
- Release 状态可能需要二次验证(GitLink API bug)
|
||
- Dashboard HTML 文件可以用浏览器打开查看
|
||
- 协同发版前建议先预览各仓库状态
|
||
|
||
## References
|
||
|
||
- [gitlink-repo](../../gitlink-repo/SKILL.md) — 仓库操作
|
||
- [gitlink-issue](../../gitlink-issue/SKILL.md) — Issue 操作
|
||
- [gitlink-pr](../../gitlink-pr/SKILL.md) — PR 操作
|
||
- [gitlink-release](../../gitlink-release/SKILL.md) — Release 操作
|
||
- [gitlink-org](../../gitlink-org/SKILL.md) — 组织管理
|