chore(deploy): document auto restart flow

This commit is contained in:
2026-07-06 11:01:42 +08:00
parent 3c3be86d24
commit 2d736f00ba
3 changed files with 203 additions and 11 deletions
+30 -8
View File
@@ -91,16 +91,38 @@ bump_version() {
echo "$new_version"
}
source_env_file() {
local file="$1"
if [ ! -f "$file" ]; then
return 1
fi
echo "读取环境变量文件: $file"
set -a
# shellcheck disable=SC1090
source "$file" 2>/dev/null || true
set +a
return 0
}
# 清除 Cloudflare CDN 缓存
# 凭据从 .env.local 读(CF_ZONE_ID / CF_API_TOKEN
# 凭据按当前分支读取:
# main → .env.production
# 其他 → .env.local
purge_cdn_cache() {
# 从 .env.local 读 CDN 凭据(Next.js 不读取,bash 直接 source
if [ -f .env.local ]; then
# shell 解析 KEY=VALUE(忽略注释 / 引号)
set -a
# shellcheck disable=SC1091
source .env.local 2>/dev/null || true
set +a
local current=$(git branch --show-current 2>/dev/null || echo "unknown")
local primary_env=".env.local"
local fallback_env=".env.production"
if [ "$current" = "main" ]; then
primary_env=".env.production"
fallback_env=".env.local"
fi
source_env_file "$primary_env" || true
if [ -z "$CF_ZONE_ID" ] || [ -z "$CF_API_TOKEN" ]; then
source_env_file "$fallback_env" || true
fi
if [ -z "$CF_ZONE_ID" ] || [ -z "$CF_API_TOKEN" ]; then