auto-sync: 2026-06-07 11:46:26
Deploy / ci (push) Waiting to run
Deploy / deploy (push) Blocked by required conditions
Deploy / notify-deploy-failure (push) Blocked by required conditions

This commit is contained in:
cfdaily
2026-06-07 11:46:26 +08:00
parent 045ee4fe81
commit 242801aab7
+33 -19
View File
@@ -1460,20 +1460,20 @@ Skill 只放共通的、所有项目都能用的技能:
工具链特有的流程("CI 失败后怎么做"、"Review 通过后怎么做")全部固化在 Mail 模板里。
### §15.7 Agent ID Git 用户名映射
### §15.7 Agent ID = Git 用户名(已确认一致)
CI workflow 和 Webhook 中的用户标识是 Git 用户名,Mail API 需要 Agent ID
姜维确认(2026-06-07):Gitea 注册用户名就是完整 Agent ID,短名用户已删除。
| Git 用户名 | Agent ID |
|-----------|----------|
| zhangfei | zhangfei-dev |
| jiangwei | jiangwei-infra |
| simayi | simayi-challenger |
| pangtong-fujunshi | pangtong-fujunshi |
| guanyu-dev | guanyu-dev |
| zhaoyun-data | zhaoyun-data |
| Agent ID= Git 用户名) |
|-------------------------|
| pangtong-fujunshi |
| simayi-challenger |
| zhangfei-dev |
| guanyu-dev |
| zhaoyun-data |
| jiangwei-infra |
daemon Webhook 模块中维护此映射表
不需要映射表,`to_agent_id()` 直用
---
@@ -1567,7 +1567,7 @@ daemon 内部 ───────┘ │ 5. 创建 Mail │
|------|---------|---------|
| Gitea Webhook | Gitea 主动 POST | PR opened, Review submitted, Issue assigned, issue_comment |
| CI workflow | CI 写 PR comment → 触发 issue_comment Webhook | CI 失败 |
| Deploy workflow | Deploy 写 PR comment → 触发 issue_comment Webhook | 部署成功/失败 |
| Deploy workflow | Deploy 创建 Issue → 触发 issues Webhook | 部署失败 |
| daemon 内部 | 内部函数调用 | 预留,当前不走中枢 |
### 2.2 事件处理矩阵
@@ -1746,6 +1746,21 @@ async def handle_gitea_webhook(
每个事件类型一个处理函数,职责:解析 payload → 选模板 → 填充 → 创建 Mail Task。
```python
async def handle_issues(engine: TemplateEngine, event: dict) -> str:
"""issues 事件分发:assigned → 通知被指派人;opened + 标题匹配 → 部署失败通知"""
action = event.get("action")
if action == "assigned":
return await _handle_issue_assigned(engine, event)
if action == "opened":
title = event.get("issue", {}).get("title", "")
if "部署失败" in title:
return await _handle_deploy_failure(engine, event)
return None # 忽略其他 action
async def handle_pull_request(engine: TemplateEngine, event: dict) -> str:
"""pull_request 事件分发:只处理 opened,忽略 synchronized/closed/reopened"""
if event.get("action") != "opened":
@@ -1831,12 +1846,11 @@ async def handle_issue_comment(engine: TemplateEngine, event: dict) -> str:
# HANDLERS 注册表
# pull_request 和 issues 只处理特定 action,在函数内部过滤
HANDLERS = {
"pull_request": handle_pull_request, # 内部只处理 opened,忽略其他 action
"pull_request": handle_pull_request, # 只处理 opened
"pull_request_review": handle_review_submitted,
"issues": handle_issues, # 内部只处理 assigned,忽略其他 action
"issue_comment": handle_issue_comment,
"issues": handle_issues, # 处理 assigned + opened(部署失败)
"issue_comment": handle_issue_comment, # 只处理 CI 失败评论
}
```
@@ -1993,7 +2007,7 @@ CI workflow 已有 `notify-on-failure` jobci.yml),当前格式:
|------|------|------|
| 1 | `toolchain_routes.py` 骨架 + Gitea Webhook 接收 + 签名验证 | 无 |
| 2 | `toolchain_templates.py` 模板引擎 | 无 |
| 3 | 6 个模板文件 | 步骤 2 |
| 3 | 5 个模板文件 | 步骤 2 |
| 4 | 4 个事件处理器(PR/Review/Issue/Comment | 步骤 1+3 |
| 5 | 幂等检查(SQLite events 表,保留 7 天) | 步骤 1 |
| 6 | `create_mail_task` 共用函数(从 mail_routes.py 提取) | 无 |
@@ -2007,11 +2021,11 @@ CI workflow 已有 `notify-on-failure` jobci.yml),当前格式:
|------|------|------|
| `src/api/toolchain_routes.py` | ~200 | 新增 |
| `src/daemon/toolchain_templates.py` | ~60 | 新增 |
| `templates/toolchain/*.md` | ~2006个文件) | 新增 |
| `templates/toolchain/*.md` | ~1705个文件) | 新增 |
| `src/api/mail_routes.py` | ~20 | 修改(提取共用函数) |
| `.gitea/workflows/ci.yml` | ~15 | 修改(加 comment step |
| `.gitea/workflows/deploy.yml` | ~15 | 修改(加 comment step |
| **总计** | **~510** | |
| **总计** | **~480** | |
---