ci: 新增 Gitea Actions 自动部署工作流(push main 自动构建 app/ui 镜像并部署 hxtesting 测试服);修复 scripts 可执行位
This commit is contained in:
1 parent
9058149576
commit
d03e024d59
23 files changed
+56
No files matched your search
@@ -0,0 +1,55 @@
|
||||
# hxtesting 测试服自动部署
|
||||
# 触发:push 到 main(同事更新代码后自动构建部署),也支持手动触发
|
||||
# 执行:hxtesting 宿主上的 gitea-runner(label=deploy-host,host 模式)
|
||||
# 说明:构建 app/frontend 镜像并顶替同名 latest tag,docreader/sandbox 等沿用官方镜像;
|
||||
# 每次构建额外打 sha-<短提交> tag 便于回滚。
|
||||
name: deploy-hxtesting
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: deploy-host
|
||||
timeout-minutes: 40
|
||||
env:
|
||||
DEPLOY_DIR: /home/lisq/services/ai_academy
|
||||
steps:
|
||||
- name: 同步代码
|
||||
run: |
|
||||
set -e
|
||||
cd "$DEPLOY_DIR"
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
echo "GIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
|
||||
echo "当前部署提交: $(git log --oneline -1)"
|
||||
|
||||
- name: 构建镜像(app + frontend,ARM64 原生)
|
||||
run: |
|
||||
set -e
|
||||
cd "$DEPLOY_DIR"
|
||||
bash scripts/build_images.sh -p
|
||||
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}
|
||||
docker image prune -f --filter "until=168h" >/dev/null
|
||||
|
||||
- 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/; then
|
||||
echo "WEB_OK: http://hxtesting/ 已可访问 (sha-${GIT_SHA})"
|
||||
else
|
||||
echo "健康检查失败,容器状态:"
|
||||
cd "$DEPLOY_DIR" && docker compose ps
|
||||
exit 1
|
||||
fi
|
||||
@@ -6,6 +6,7 @@
|
||||
!.gitignore
|
||||
!.gitattributes
|
||||
!.github/
|
||||
!.gitea/
|
||||
!.dockerignore
|
||||
!.golangci.yml
|
||||
!.air.toml
|
||||
|
||||
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Regular → Executable
File mode changed.
Reference in new issue
Block a user