chore(release): deploy-from-committed 防呆流程(git 閘 + 清單)
壓測階段 6 抓到漂移新形態:cypher 改了但沒推 main → acr init 從 origin/main codeload 抓到舊 worker → 薄殼打不存在的 /init/seed → 404。根因是「deploy 前沒先 push」。 防呆(沒 GH Actions,deploy 分開推,靠清單+閘不漏): - scripts/check-release.sh 加「0. Git 同步」段:工作目錄髒 / 領先 origin/main 未 push → exit 1 - scripts/local-deploy.sh 實際 deploy 前強制跑 git 閘(未過拒絕 deploy;SKIP_GIT_CHECK=true 可強推) - RELEASE-CHECKLIST.md:正確順序(先 commit+push main → 再 deploy → 線上打新端點驗證) 核心鐵則:self-hosted acr init 從 origin/main 抓 worker 源,故 git push 必須在 deploy 之前。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,38 @@ echo ""
|
||||
echo "═══ arcrun release 狀態檢查(release.feature 佐證)═══"
|
||||
echo ""
|
||||
|
||||
# ── 0. Git 同步(最關鍵:self-hosted 從 origin/main codeload 抓 worker)──────
|
||||
# 壓測階段 6 抓到的漂移:CLI 新(npm)但 worker 舊(main 沒推 init-seed)→ acr init
|
||||
# 從 main 抓到舊 cypher → 薄殼打不存在的 API → 404。
|
||||
# ∴ deploy 前 git 必須先 push main,否則 self-hosted 用戶裝到舊碼。
|
||||
echo "【0. Git 同步(deploy 前必過——self-hosted 從 origin/main 抓 worker 源)】"
|
||||
GIT_BLOCK=0
|
||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
||||
DIRTY=$(git status --porcelain 2>/dev/null | grep -v '^?? ' | head -1)
|
||||
if [ -n "$DIRTY" ]; then
|
||||
err "工作目錄有未 commit 的變動 → deploy 前先 commit(否則部署的不是 GitHub 上的碼)"
|
||||
GIT_BLOCK=1
|
||||
else
|
||||
ok "工作目錄乾淨(無未 commit 追蹤檔變動)"
|
||||
fi
|
||||
# local main vs origin/main
|
||||
git fetch origin "$BRANCH" --quiet 2>/dev/null || true
|
||||
AHEAD=$(git rev-list --count "origin/$BRANCH..$BRANCH" 2>/dev/null || echo "?")
|
||||
BEHIND=$(git rev-list --count "$BRANCH..origin/$BRANCH" 2>/dev/null || echo "?")
|
||||
if [ "$AHEAD" = "0" ] && [ "$BEHIND" = "0" ]; then
|
||||
ok "$BRANCH 與 origin/$BRANCH 同步(self-hosted codeload 會抓到最新 worker)"
|
||||
elif [ "$AHEAD" != "0" ] && [ "$AHEAD" != "?" ]; then
|
||||
err "$BRANCH 領先 origin/$BRANCH $AHEAD 個 commit 未 push → **deploy 前先 git push**(否則 self-hosted 裝到舊 worker,重演壓測階段 6 的 seed 404)"
|
||||
GIT_BLOCK=1
|
||||
else
|
||||
warn "$BRANCH vs origin/$BRANCH:ahead=$AHEAD behind=$BEHIND(確認狀態)"
|
||||
fi
|
||||
else
|
||||
info "非 git repo,跳過 git 同步檢查"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# ── 1. CF Worker 部署單位(由 scripts/local-deploy.sh 掃描部署)──────────
|
||||
# 註:GH Actions 2026-05-16 停用、公開 repo 已移除 .github/,現行 deploy 走 local-deploy.sh。
|
||||
echo "【CF Workers(scripts/local-deploy.sh 掃 wrangler.toml 後 wrangler deploy)】"
|
||||
@@ -87,5 +119,11 @@ else
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "═══ 完成。⚠ = 需注意;· = 資訊;✗ = 失敗 ═══"
|
||||
if [ "$GIT_BLOCK" = "1" ]; then
|
||||
echo "═══ ✗ Git 未同步 — deploy 前必須先 commit + git push(見上「0. Git 同步」)═══"
|
||||
echo " 流程見 RELEASE-CHECKLIST.md。push 完再跑本檢查確認全綠。"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
echo "═══ ✓ 可 deploy。⚠ = 需注意;· = 資訊;✗ = 失敗。流程見 RELEASE-CHECKLIST.md ═══"
|
||||
echo ""
|
||||
|
||||
@@ -149,6 +149,22 @@ if [[ "$DRY_RUN" == true ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ── 3.5 Git 同步前置閘(壓測階段 6 教訓:deploy-from-committed)────────────────
|
||||
# self-hosted `acr init` 從 origin/main codeload 抓 worker 源。若本機領先 main 未 push,
|
||||
# 部署 prod 用的是新碼但 self-hosted 用戶抓到舊碼 → 薄殼打不存在的 API(seed 404)。
|
||||
# ∴ 實際 deploy 前強制 git 同步檢查;未過用 --skip-git-check 可強制略過(自負風險)。
|
||||
if [[ "${SKIP_GIT_CHECK:-false}" != "true" ]]; then
|
||||
echo ""
|
||||
echo "🔎 Git 同步前置檢查(deploy 前必過;要略過設 SKIP_GIT_CHECK=true)..."
|
||||
if ! bash scripts/check-release.sh >/tmp/arcrun-release-check.txt 2>&1; then
|
||||
grep -E "✗|⚠|領先|未 commit|Git 未同步" /tmp/arcrun-release-check.txt | sed 's/^/ /'
|
||||
echo "❌ Git 未同步 → 先 commit + git push 再 deploy(見 RELEASE-CHECKLIST.md)。"
|
||||
echo " (確定要在未 push 狀態 deploy? SKIP_GIT_CHECK=true bash scripts/local-deploy.sh ...)"
|
||||
exit 1
|
||||
fi
|
||||
echo " ✓ Git 已同步,繼續 deploy"
|
||||
fi
|
||||
|
||||
# ── 4. wrangler whoami 健康檢查 ──────────────────────────────────────────────
|
||||
|
||||
# 隨便挑一個 worker dir 跑 whoami(pnpm 需要在 npm package 內)
|
||||
|
||||
Reference in New Issue
Block a user