fix(deploy): improve webhook auto-release reliability and deploy.sh defaults

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-10 12:44:49 +08:00
parent 47f540fbd9
commit ffd9180315
3 changed files with 59 additions and 17 deletions
+11 -12
View File
@@ -11,7 +11,7 @@ DEPLOY_PORT="22"
DEPLOY_SSH_KEY=""
APP_ROOT="/opt/dukang-haoke"
GIT_REMOTE="origin"
GIT_BRANCH="main"
GIT_BRANCH="dev"
CHECK_ONLY=false
RELEASE_ARGS=()
@@ -27,7 +27,7 @@ usage() {
--user USER SSH 用户,默认 root
--port PORT SSH 端口,默认 22
--key PATH SSH 私钥路径
--branch BRANCH 发布分支,默认 main
--branch BRANCH 发布分支,默认 dev
--check 仅 SSH 连接并查看 PM2 / 端口状态
-h, --help 显示帮助
@@ -108,17 +108,16 @@ if [[ ! -d .git ]]; then
exit 1
fi
echo "==> 拉取代码"
git fetch "\$GIT_REMOTE"
git checkout "\$GIT_BRANCH"
git pull --ff-only "\$GIT_REMOTE" "\$GIT_BRANCH"
if [[ ! -f deploy/remote-release.sh ]]; then
echo "错误: deploy/remote-release.sh 不存在,请先推送部署脚本到仓库" >&2
exit 1
if [[ -n "\$RELEASE_ARGS" ]]; then
echo "==> 拉取代码"
git fetch "\$GIT_REMOTE"
git checkout "\$GIT_BRANCH"
git pull --ff-only "\$GIT_REMOTE" "\$GIT_BRANCH"
bash deploy/remote-release.sh \$RELEASE_ARGS
else
echo "==> 拉取代码并发布(auto-release"
bash deploy/auto-release.sh
fi
bash deploy/remote-release.sh \$RELEASE_ARGS
EOF
echo "==> 本地发布命令已完成"