Files
sundynix-agentix/.gitea/workflows/deploy.yml
T
Blizzard da0d964054 ci(gitea): 部署目录改为 /home/workspace/sundynix-agentix
与 sundynix-site 的 /home/workspace/ 一致(用户实际部署路径)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 15:11:10 +08:00

71 lines
2.6 KiB
YAML
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.
name: deploy-132
# 只认 main(含 PR 合并入 main)。runner 在 128,应用部署到 132
# runner 检出 → rsync 仓库到 132 → 在 132 本地 docker compose up -d --build → 健康检查。
# 在 132 构建、132 运行:不把 4 个大镜像塞去 128 构建(128 是基础设施机)。
on:
push:
branches: [main]
workflow_dispatch:
env:
REMOTE_DIR: /home/workspace/sundynix-agentix
jobs:
deploy:
runs-on: ubuntu-latest # 须匹配 128 上已注册 runner 的标签;不符请改成你的标签
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 安装 ssh / rsync 工具
run: |
if command -v apt-get >/dev/null; then
apt-get update && apt-get install -y sshpass openssh-client rsync
elif command -v apk >/dev/null; then
apk add --no-cache sshpass openssh-client rsync
fi
- name: rsync 仓库到 132
env:
SSHPASS: ${{ secrets.DEPLOY_PASSWORD }}
run: |
H="${{ secrets.DEPLOY_HOST }}"
U="${{ secrets.DEPLOY_USER }}"
sshpass -e ssh -o StrictHostKeyChecking=no "$U@$H" "mkdir -p $REMOTE_DIR"
# 同步源码;排除本地产物与密钥(132 上的 .env 由你手工放置,绝不被覆盖/删除)。
sshpass -e rsync -az --delete \
--exclude '.git' \
--exclude 'node_modules' \
--exclude '**/node_modules' \
--exclude '**/dist' \
--exclude '.env' \
--exclude '**/.env' \
-e "ssh -o StrictHostKeyChecking=no" \
./ "$U@$H:$REMOTE_DIR/"
- name: 132 本地构建并起服务
env:
SSHPASS: ${{ secrets.DEPLOY_PASSWORD }}
run: |
H="${{ secrets.DEPLOY_HOST }}"
U="${{ secrets.DEPLOY_USER }}"
sshpass -e ssh -o StrictHostKeyChecking=no "$U@$H" "\
cd $REMOTE_DIR/deploy/132-app && \
docker compose up -d --build && \
docker image prune -f"
- name: 健康检查(gateway :3000/healthz
env:
SSHPASS: ${{ secrets.DEPLOY_PASSWORD }}
run: |
H="${{ secrets.DEPLOY_HOST }}"
U="${{ secrets.DEPLOY_USER }}"
sshpass -e ssh -o StrictHostKeyChecking=no "$U@$H" "\
for i in \$(seq 1 20); do \
curl -sf http://127.0.0.1:3000/healthz && echo ' ✅ 健康' && exit 0; \
sleep 3; \
done; \
echo '❌ 健康检查失败'; \
cd $REMOTE_DIR/deploy/132-app && docker compose logs --tail 50 gateway; exit 1"