ci(deploy): deploy.sh 支持本地直跑模式 + workflow 健康检查读取 .env PORT
Some checks failed
CI / check (pull_request) Failing after 5m3s

- deploy.sh 默认本地直跑(./deploy.sh 或 ./deploy.sh local),不再需要 SSH;传 ssh_host 才走远程版
- workflow 健康检查从 .env 读取 PORT(默认 3000),适配 PORT=3002 等自定义端口
This commit is contained in:
2026-08-09 22:04:21 +08:00
parent f4072ce93a
commit 9d74bd2d51
2 changed files with 80 additions and 33 deletions

View File

@@ -75,7 +75,10 @@ jobs:
run: |
cd ${{ vars.REMOTE_DIR || '/opt/gongxue' }}
sleep 3
code="$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/api/dashboard/stats || true)"
# 从 .env 读 PORT默认 3000避免硬编码端口与后端不一致
PORT="$(grep '^PORT=' .env 2>/dev/null | cut -d= -f2- | tr -d '"' || true)"
PORT="${PORT:-3000}"
code="$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:${PORT}/api/dashboard/stats" || true)"
echo "后端 HTTP 状态: ${code}401=正常,接口需登录)"
if [ "${code}" != "401" ] && [ "${code}" != "200" ]; then
echo "健康检查失败:后端未按预期响应" >&2