Files
wecom-ai-assistant/docs/phase7.md
2026-02-05 16:36:32 +08:00

1.7 KiB
Raw Permalink Blame History

Phase 7云端 CI/CD + 线上回调稳定 + 最小闭环验收

CI/CDGitHub Actions

  • 位置.github/workflows/build-deploy.yml(副本说明见 deploy/ci/
  • 触发:推送到 main 分支
  • 流程
    1. test-backend:启动 PostgreSQL 16执行迁移运行 pytest tests/
    2. build-backend:构建 backend 镜像并推送到 GitHub Container Registryghcr.io/<owner>/wecom-ai-backend:latest
    3. build-admin:构建 admin 镜像并推送(ghcr.io/<owner>/wecom-ai-admin:latest

云端部署(方案 A

  1. 服务器安装 Docker + docker-compose。
  2. 从 GHCR 拉取镜像(或从仓库 build
    • 使用 docker-compose.yml 时,可改为使用 image: ghcr.io/<owner>/wecom-ai-backend:latest 等,不再本地 build。
  3. 配置 .env(含 WECOM_*DATABASE_URLJWT_SECRET 等)。
  4. 执行:docker-compose up -d
  5. 配置 Nginx 反代或直接暴露端口HTTPS 证书后补。

无 GitHub 时GitLab CI 替代)

在仓库根目录创建 .gitlab-ci.yml,阶段与上述对应:
testpostgres service + migrate + pytestbuilddocker build + push 到 GitLab Registry。变量使用 CI_REGISTRYCI_REGISTRY_USERCI_REGISTRY_PASSWORD

最小闭环验收脚本

  • 路径deploy/scripts/acceptance.sh
  • 用法BASE_URL=http://localhost ./acceptance.shBASE_URL=https://你的域名 ./acceptance.sh
  • 步骤
    1. GET /api/health 期望 200
    2. POST /api/auth/loginadmin/admin期望 code: 0
    3. GET /api/wecom/callback?... 期望 200 或 400验签失败为 400

全部通过即打印 "All checks passed"。