From 5847d89213ecb9ce7d410f34f1b875750bc2b397 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Thu, 16 Jul 2026 21:12:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=9B=BA=E9=80=9A=E7=9F=A5=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E5=8F=91=E5=B8=83=E4=BC=A0=E8=BE=93=E4=B8=8E=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/git-build-deploy.ps1 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/git-build-deploy.ps1 b/scripts/git-build-deploy.ps1 index 64c7a06..4db7250 100644 --- a/scripts/git-build-deploy.ps1 +++ b/scripts/git-build-deploy.ps1 @@ -34,7 +34,7 @@ log() { printf '[INFO] %s\n' "$*"; } ok() { printf '[OK] %s\n' "$*"; } fail() { printf '[ERR] %s\n' "$*" >&2; exit 1; } -for command in git docker curl ssh; do +for command in git docker curl ssh base64; do command -v "$command" >/dev/null 2>&1 || fail "构建机缺少命令: $command" done curl -fsS "http://127.0.0.1:${REGISTRY_HOST##*:}/v2/" >/dev/null \ @@ -160,8 +160,21 @@ if [ "$healthy" != 1 ]; then exit 1 fi +public_healthy=0 +for _ in $(seq 1 15); do + if curl -fsS --max-time 5 https://sc.jiansun.vip/notification-center/health >/tmp/yyd-notification-public-health.json; then + public_healthy=1 + break + fi + sleep 2 +done +if [ "$public_healthy" != 1 ]; then + echo '通知中心公网健康检查持续失败,保留本机健康的新容器以便排查反向代理。' >&2 + exit 1 +fi + printf '%s' "$COMMIT_SHA" > DEPLOYED_COMMIT -curl -fsS --max-time 10 https://sc.jiansun.vip/notification-center/health +cat /tmp/yyd-notification-public-health.json printf '\nDEPLOYED_COMMIT=' cat DEPLOYED_COMMIT printf '\nCONTAINER_IMAGE=' @@ -170,8 +183,9 @@ printf '\n' PRODUCTION )" -printf '%s\n' "$production_script" | ssh -o BatchMode=yes "$PRODUCTION_SERVER" \ - "REMOTE_IMAGE='$remote_commit' IMAGE_TAG='$image_tag' COMMIT_SHA='$commit_sha' bash -s" +production_script_base64="$(printf '%s\n' "$production_script" | base64 | tr -d '\n')" +ssh -o BatchMode=yes "$PRODUCTION_SERVER" \ + "printf '%s' '$production_script_base64' | base64 -d | REMOTE_IMAGE='$remote_commit' IMAGE_TAG='$image_tag' COMMIT_SHA='$commit_sha' bash -s" ok "通知中心已部署到 ${commit_sha}" '@