CI Failure Fixer
Monitor GitHub Actions for failures. Auto-fix what's fixable, report what's not.
How It Works
- 1.
scripts/check-ci-failures.sh polls repos for new failed runs - If failures found → read build logs via INLINECODE1
- Match error against known patterns → auto-fix if safe
- Push fix → wait 90s → verify build passes
- Report results (fixed or diagnosis-only)
Quick Start
On-demand
CODEBLOCK0
Output: OK (no failures) or FAILURES with details.
As Cron Job (OpenClaw)
Set up a cron that runs every 30 minutes:
- - Script: INLINECODE4
- Model: Haiku (cheap, sufficient)
- On failure: Read logs, attempt auto-fix, report
Configuration
Environment variables:
- -
GITHUB_OWNER — GitHub username (auto-detected from gh if not set) - INLINECODE7 — Space-separated repo names (auto-discovers all repos if not set)
- INLINECODE8 — Path to state JSON (tracks last check time)
Auto-Fixable Patterns
| Pattern | Detection | Fix |
|---|
| Dependency issues | INLINECODE9 | INLINECODE10 + push |
| Test snapshots |
Snapshot mismatch |
npm test -- --update + push |
| Lint errors |
eslint,
Formatting |
eslint --fix + push |
| E2E snapshots | Playwright snapshot diff |
playwright --update-snapshots + push |
Report-Only (Human Needed)
- - Token/auth errors (secrets rotation)
- TypeScript errors (complex type issues)
- Build timeouts (resource/loop issues)
- Unknown errors
Fix Patterns Reference
Read references/fix-patterns.md for detailed decision tree, log reading commands, and all known patterns with fix scripts.
Reading Logs
CODEBLOCK1
After Fixing
Always verify the fix worked:
CODEBLOCK2
CI失败修复器
监控GitHub Actions中的失败。自动修复可修复的问题,报告无法修复的问题。
工作原理
- 1. scripts/check-ci-failures.sh 轮询仓库以查找新的失败运行
- 如果发现失败 → 通过 gh run view --log 读取构建日志
- 将错误与已知模式匹配 → 如果安全则自动修复
- 推送修复 → 等待90秒 → 验证构建通过
- 报告结果(已修复或仅诊断)
快速开始
按需运行
bash
bash scripts/check-ci-failures.sh
输出:OK(无失败)或 FAILURES(附带详情)。
作为定时任务(OpenClaw)
设置每30分钟运行一次的定时任务:
- - 脚本: bash scripts/check-ci-failures.sh
- 模型: Haiku(廉价且足够)
- 失败时: 读取日志,尝试自动修复,报告结果
配置
环境变量:
- - GITHUBOWNER — GitHub用户名(如未设置,从 gh 自动检测)
- CIREPOS — 以空格分隔的仓库名称(如未设置,自动发现所有仓库)
- CISTATEFILE — 状态JSON文件路径(跟踪上次检查时间)
可自动修复的模式
| 模式 | 检测 | 修复 |
|---|
| 依赖问题 | npm ERR! Could not resolve | npm install + 推送 |
| 测试快照 |
Snapshot mismatch | npm test -- --update + 推送 |
| Lint错误 | eslint, Formatting | eslint --fix + 推送 |
| E2E快照 | Playwright快照差异 | playwright --update-snapshots + 推送 |
仅报告(需要人工处理)
- - 令牌/认证错误(密钥轮换)
- TypeScript错误(复杂类型问题)
- 构建超时(资源/循环问题)
- 未知错误
修复模式参考
阅读 references/fix-patterns.md 获取详细的决策树、日志读取命令以及所有已知模式及其修复脚本。
读取日志
bash
最新失败运行的日志
gh run view --repo OWNER/REPO --log 2>&1 | tail -50
过滤错误
gh run view
--repo OWNER/REPO --log 2>&1 | grep -A5 error\|FAIL
修复后
始终验证修复是否生效:
bash
sleep 90 # 等待新的CI运行
gh run list --repo OWNER/REPO --limit 1 --json conclusion -q .[0].conclusion
应为 success