auto-sync: 2026-06-07 11:35:35
This commit is contained in:
@@ -1579,7 +1579,7 @@ daemon 内部 ───────┘ │ 5. 创建 Mail │
|
||||
| `issues` assigned | Gitea Webhook | 被指派人 | `issue_assigned.md` | Issue号、标题、标签、描述、分支名建议 |
|
||||
| `issue_comment` (CI失败) | CI workflow → Webhook | PR 作者 | `ci_failure.md` | PR号、分支、失败步骤、错误摘要 |
|
||||
| ~~部署成功~~ | ~~不需要通知~~ | ~~流程自动闭环~~ | ~~—~~ | ~~Gitea Issue 自动关闭~~ |
|
||||
| `issue_comment` (部署失败) | Deploy workflow → Webhook | 庞统 + 姜维 | `deploy_failure.md` | 仓库、失败原因、已回滚版本 |
|
||||
| `issues` created (标题匹配 🔴 部署失败) | Deploy workflow → Webhook | 姜维 + 庞统 | `deploy_failure.md` | 仓库、commit、失败原因 |
|
||||
|
||||
### 2.3 事件过滤规则
|
||||
|
||||
@@ -1588,7 +1588,7 @@ daemon 内部 ───────┘ │ 5. 创建 Mail │
|
||||
| 规则 | 说明 |
|
||||
|------|------|
|
||||
| 只处理白名单内的事件类型 | 未知的忽略 + 日志 |
|
||||
| issue_comment 需判断来源 | 只处理 CI/deploy workflow 写的评论(按特定前缀匹配,如 `[CI]`、`[Deploy]`) |
|
||||
| issue_comment 需判断来源 | 只处理 CI workflow 写的评论(按特定前缀匹配:`❌ **CI 失败**` 或统一后的 `[CI]` 前缀) |
|
||||
| PR 作者/审查者必须是已知 Agent | 未知的忽略 + 日志 |
|
||||
| 幂等:同一事件不重复创建 Mail | 按 `{x_gitea_event}-{x_gitea_delivery}` 去重(delivery ID 来自 `X-Gitea-Delivery` header) |
|
||||
|
||||
@@ -1821,10 +1821,11 @@ async def handle_issue_comment(engine: TemplateEngine, event: dict) -> str:
|
||||
"""issue_comment → 判断来源,路由到 CI/部署通知"""
|
||||
comment_body = event["comment"]["body"]
|
||||
|
||||
if comment_body.startswith("[CI]"):
|
||||
# 匹配 CI workflow 写的失败评论(当前格式: "❌ **CI 失败**",未来统一为 "[CI]")
|
||||
if "[CI]" in comment_body or "CI 失败" in comment_body:
|
||||
return await handle_ci_comment(engine, event)
|
||||
elif comment_body.startswith("[Deploy"):
|
||||
return await handle_deploy_comment(engine, event)
|
||||
# 部署失败当前走创建 Issue(不走 PR comment),见 §16.8 #6
|
||||
return None
|
||||
|
||||
return None # 非 CI/部署评论不处理
|
||||
|
||||
@@ -1931,20 +1932,20 @@ class TemplateEngine:
|
||||
|
||||
### 6.1 CI 失败通知
|
||||
|
||||
CI workflow 失败时写 PR comment,触发 issue_comment Webhook:
|
||||
CI workflow 已有 `notify-on-failure` job(ci.yml),当前格式:
|
||||
```
|
||||
❌ **CI 失败**
|
||||
|
||||
请检查 CI 日志并修复。
|
||||
|
||||
触发 commit: `abc1234`
|
||||
```
|
||||
|
||||
**需要修改**:将 comment 前缀统一为 `[CI]`,方便中枢匹配:
|
||||
```yaml
|
||||
# .gitea/workflows/ci.yml
|
||||
- name: Report failure
|
||||
if: failure()
|
||||
run: |
|
||||
curl -s -X POST \
|
||||
"http://192.168.2.154:3000/api/v1/repos/{owner}/{repo}/issues/{pr_number}/comments" \
|
||||
-H "Authorization: token ${{ secrets.CI_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"body\": \"[CI] CI 失败\\n\\n分支: ${{ gitea.ref_name }}\\n失败步骤: ${{ job.status }}\\n错误摘要: $(tail -20 $GITHUB_STEP_SUMMARY)\"
|
||||
}"
|
||||
# .gitea/workflows/ci.yml — notify-on-failure job
|
||||
-d "{\"body\": \"❌ **CI 失败**\\n\\n请检查 CI 日志并修复。\"}"
|
||||
+d "{\"body\": \"[CI] 失败\\n\\n分支: ${{ gitea.ref_name }}\\n触发 commit: \\`${{ gitea.sha }}\\`\\n请检查日志并修复。\"}"
|
||||
```
|
||||
|
||||
### 6.2 Deploy 结果通知
|
||||
|
||||
Reference in New Issue
Block a user