forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson-dco-auto-fix-workflow.json
More file actions
16 lines (16 loc) · 1.69 KB
/
Copy pathlesson-dco-auto-fix-workflow.json
File metadata and controls
16 lines (16 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"task_id": "lesson-dco-auto-fix-workflow",
"title": "DCO 自动修复工作流 — /fix-dco 命令设计与实现",
"domain": "devops",
"tags": [
"github-actions",
"dco",
"signoff",
"issue_comment",
"auto-fix"
],
"problem": "贡献者提交 PR 后 DCO(Signed-off-by)检查失败是最常见的阻塞原因之一。尤其是 AI Agent 自动提交的 PR,经常缺签。需要在 PR 评论区提供一键自动修复能力。",
"solution": "利用 `issue_comment` 事件 + `pull_request_target` 安全模型,实现 `/fix-dco` 命令。\n\n### 工作流核心逻辑\n\n```yaml\non:\n issue_comment:\n types: [created]\n\njobs:\n fix-dco:\n if: |\n github.event.issue.pull_request &&\n contains(github.event.comment.body, '/fix-dco') &&\n (github.event.comment.user.login == github.event.issue.user.login ||\n contains(fromJSON('[\"MEMBER\",\"OWNER\",\"COLLABORATOR\"]'), ...))\n```\n\n### 分支处理\n\n**同仓库 PR**(head repo = 目标仓库):\n1. 检出 PR 头部分支(`refs/pull/<num>/head`)\n2. 执行 `git rebase --signoff origin/main` 或 `git rebase --signoff HEAD~N`\n3. Force-push 回原分支\n4. 回复 ✅ 成功\n\n**Fork PR**(head repo ≠ 目标仓库):\n- GITHUB_TOKEN 无权 push 到 fork\n- 回复手动修复指引:\n ```\n git rebase --signoff HEAD~N\n git push --force\n ```\n\n### 安全限制\n\n- 仅允许 PR 作者、MEMBER、OWNER、COLLABORATOR 触发\n- 最多自动修复 10 个 commit(超过则要求手动修复)\n- 需要 `contents: write` + `pull-requests: write` 权限",
"source": "lessons/dco-auto-fix-workflow.md",
"test_cmd": "python3 scripts/verify_task.py lesson-dco-auto-fix-workflow"
}