ci(deploy): deploy.sh 支持本地直跑模式 + workflow 健康检查读取 .env PORT
Some checks failed
CI / check (pull_request) Failing after 5m3s
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user