- 升级 Anthropic API 配置支持自定义 base URL - 更新模型版本到 claude-sonnet-4-6 - 添加 QuestionResponse.user_id 字段 - 完善 docker-compose.yml 添加 backend 和 celery 服务 - 新增项目文档(API、部署、架构等) - 添加测试脚本和配置文件 Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
5.1 KiB
5.1 KiB
自动修复系统和组织仓库更新完成
✅ 完成的工作
1. 更新部署仓库为组织仓库
变更:
- 从:
BrunoGao/ljwx-deploy - 到:
BrunoGaoSZ/ljwx-deploy
更新的文件:
.github/workflows/ci.yml- CI/CD workflow.github/workflows/README.md- 架构文档.github/workflows/SECRETS_SETUP_GUIDE.md- Secrets 设置指南.github/workflows/QUICKSTART.md- 快速开始.github/workflows/SETUP.md- 设置指南.github/workflows/INDEX.md- 文档索引
更新的 Secret:
DEPLOY_REPO=BrunoGaoSZ/ljwx-deploy
2. 创建自动修复系统
新增文件:
.github/workflows/auto-fix.yml- 自动修复 workflow.github/workflows/AUTO_FIX.md- 完整文档
功能特性:
✅ 自动错误检测
- Missing Python Module - 缺少 Python 模块
- Import Error - 导入错误
- Database Error - 数据库配置错误
- Test Failure - 测试失败
- Type Check Error - 类型检查错误
✅ 自动化流程
CI 失败 → 下载日志 → 分析错误 → 创建 Issue → 通知团队
✅ Issue 自动创建
当 CI 失败时,系统会自动创建包含以下信息的 issue:
- 失败的分支和提交
- 错误类型分析
- 相关日志链接
- 修复建议
- 快速链接
🚀 如何使用
查看自动创建的 Issue
# 列出所有 CI 失败的 issue
gh issue list --label "ci-failure"
# 查看特定 issue
gh issue view <issue-number>
监控自动修复运行
# 查看 Auto Fix workflow 运行历史
gh run list --workflow=auto-fix.yml --limit 10
# 查看特定运行的日志
gh run view <run-id> --log
手动触发分析
# 重新运行 Auto Fix workflow
gh workflow run auto-fix.yml
📊 当前 CI/CD 状态
最新运行
# 查看最新的 CI 运行
gh run list --limit 5
# 实时监控
gh run watch
预期流程
-
Test Stage (约 20 分钟)
- ✅ Linter 检查
- ✅ Type checker (optional)
- ✅ Migrations
- ✅ Tests with coverage
-
Build Stage (约 30 分钟)
- ✅ Docker 镜像构建
- ✅ 推送到 Harbor
-
Deploy Stage (约 10 分钟)
- ✅ 更新 ljwx-deploy 仓库
- ✅ 创建 PR
-
Auto Fix (如果失败)
- ✅ 分析错误
- ✅ 创建 Issue
🔧 配置说明
GitHub Secrets
确保以下 secrets 已正确配置:
# 验证 secrets
gh secret list
# 应该看到:
# HARBOR_USERNAME - Harbor 用户名
# HARBOR_PASSWORD - Harbor 密码
# DEPLOY_REPO_TOKEN - GitHub PAT (访问 ljwx-deploy)
# DEPLOY_REPO - BrunoGaoSZ/ljwx-deploy
权限要求
Auto Fix workflow 需要以下权限:
contents: write- 创建分支和提交pull-requests: write- 创建 PRissues: write- 创建 Issue
这些权限已在 .github/workflows/auto-fix.yml 中配置。
📚 文档
核心文档
快速链接
- GitHub Actions: https://github.com/BrunoGao/ljwx-shiti/actions
- 部署仓库: https://github.com/BrunoGaoSZ/ljwx-deploy
- Harbor: https://harbor.omniverseai.net/harbor/projects/ljwx
🎯 下一步
1. 等待 CI 完成
# 实时监控
gh run watch
# 或在浏览器查看
open https://github.com/BrunoGao/ljwx-shiti/actions
2. 验证部署仓库访问
# 测试 token 权限
curl -H "Authorization: token YOUR_TOKEN" \
https://api.github.com/repos/BrunoGaoSZ/ljwx-deploy
# 应该返回仓库信息
3. 检查自动修复
如果 CI 失败,检查是否自动创建了 issue:
gh issue list --label "ci-failure"
🔍 故障排查
CI 仍然失败
-
查看最新的运行日志:
gh run view --log -
检查是否创建了 auto-fix issue:
gh issue list --label "ci-failure" -
查看具体错误并手动修复
Auto Fix 未触发
- 检查 workflow 权限
- 查看 Auto Fix 运行历史:
gh run list --workflow=auto-fix.yml
部署仓库访问失败
-
验证 DEPLOY_REPO secret:
gh secret list | grep DEPLOY_REPO -
测试 token 权限:
curl -H "Authorization: token YOUR_TOKEN" \ https://api.github.com/repos/BrunoGaoSZ/ljwx-deploy
💡 未来改进
自动修复增强
- 集成 Claude API 进行智能分析
- 自动创建修复 PR
- 支持更多错误类型
- 添加 Slack/Discord 通知
监控和分析
- 错误趋势分析
- CI 性能监控
- 成功率统计
- 自动回滚机制
创建时间: 2026-02-27 最后更新: 2026-02-27
相关提交:
840b586- feat: add auto-fix workflow and update deploy repo to org2c40a0b- fix: use asyncpg driver for alembic migrations in CIca9f9e4- fix: add psycopg2-binary for alembic migrationse5526ce- ci: add GitHub Actions CI/CD pipeline