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

36 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 Registry`ghcr.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_URL``JWT_SECRET` 等)。
4. 执行:`docker-compose up -d`
5. 配置 Nginx 反代或直接暴露端口HTTPS 证书后补。
## 无 GitHub 时GitLab CI 替代)
在仓库根目录创建 `.gitlab-ci.yml`,阶段与上述对应:
`test`postgres service + migrate + pytest`build`docker build + push 到 GitLab Registry。变量使用 `CI_REGISTRY``CI_REGISTRY_USER``CI_REGISTRY_PASSWORD`
## 最小闭环验收脚本
- **路径**`deploy/scripts/acceptance.sh`
- **用法**`BASE_URL=http://localhost ./acceptance.sh``BASE_URL=https://你的域名 ./acceptance.sh`
- **步骤**
1. `GET /api/health` 期望 200
2. `POST /api/auth/login`admin/admin期望 `code: 0`
3. `GET /api/wecom/callback?...` 期望 200 或 400验签失败为 400
全部通过即打印 "All checks passed"。