Files

62 lines
2.6 KiB
YAML
Raw Permalink 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.
# ai30 生产服自动部署
# 触发:仅手动(workflow_dispatch)——生产环境人工卡点,push prod 不自动部署。
# (发布纪律 standards://workflow/release@2.0.1:生产部署需人工触发;
# 测试区走 deploy-hxtesting.yml 的 push test 触发,两者分工见 docs/deploy-hxtesting.md)
# 执行:ai30 宿主上的 gitea-runner(label=deploy-ai30,host 模式,inspur 用户)
# 说明:与 deploy-hxtesting 同构,差异三点——分支 prod、端口 8802、目标机 x86_64;
# 端口登记:8801=测试(hxtesting) / 8802=生产(ai30),均属 88xx 平台 Web 号段。
# 构建前产物 artifacts/ 与 .env 均为 gitignored,由部署管理员在 ai30 维护。
name: deploy-ai30
on:
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: deploy-ai30
timeout-minutes: 60
env:
DEPLOY_DIR: /data/ai-platform/ai_academy
steps:
- name: 同步代码
run: |
set -e
cd "$DEPLOY_DIR"
git fetch origin
git checkout -q -B prod origin/prod
echo "GIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
echo "当前部署提交: $(git log --oneline -1)"
- name: 构建镜像(app + frontend,x86_64 原生)
run: |
set -e
cd "$DEPLOY_DIR"
# WITH_ANYDOC=0:跳过 anydoc 解析引擎(Rust 工具链需外网;文档解析由 docreader 容器承担)
WITH_ANYDOC=0 bash scripts/build_images.sh -p
WITH_ANYDOC=0 bash scripts/build_images.sh -f
docker tag wechatopenai/weknora-app:latest wechatopenai/weknora-app:sha-${GIT_SHA}
docker tag wechatopenai/weknora-ui:latest wechatopenai/weknora-ui:sha-${GIT_SHA}
# 仅清理本项目旧版本镜像(保留最近 5 个 sha-* 备回滚),不影响 ai30 上其他项目
for repo in wechatopenai/weknora-app wechatopenai/weknora-ui; do
docker images --format '{{.Tag}}' "$repo" | grep '^sha-' | tail -n +6 \
| xargs -r -I{} docker rmi "$repo:{}" >/dev/null 2>&1 || true
done
- name: 部署(compose up)
run: |
set -e
cd "$DEPLOY_DIR"
docker compose up -d --remove-orphans
- name: 健康检查
run: |
set -e
sleep 20
if curl -fsS -o /dev/null --max-time 10 http://127.0.0.1:8802/; then
echo "WEB_OK: http://ai30:8802/ 已可访问 (sha-${GIT_SHA})"
else
echo "健康检查失败,容器状态:"
cd "$DEPLOY_DIR" && docker compose ps
exit 1
fi