feat(deploy): 裸 clone 构建改造与 en/archives 补页(T1/T4)
- build.sh:构建源改 ~/docker_apps/blog/build-repo(fetch+reset 硬跟
origin/main,匿名 fetch)——线上=远端 main 确定性闭环,Sveltia 保存
即自动上线生效;stamp 记录构建 commit;node_modules 留仓内做增量
(loader 逻辑变更时须清 node_modules/.astro——EXIF 教训已注)
- en/archives/index.astro 补缺(此前 404):PostList locale 复用 +
译题映射;三级目录 import 深度坑再犯一次(已修)
验证: bash infra/deploy/build.sh → staging 29 html @0e792a7(裸 clone
实测);build 本地 28+1 页;E2E 30/30 PASS
Spec: 2026-10-25_add-blog-5c
Co-authored-by: GLM-5.3
This commit is contained in:
1 parent
ad5f9d3d95
commit
f8add5ad15
5 files changed
+153
-9
No files matched your search
Regular → Executable
+22
-9
@@ -1,20 +1,33 @@
|
||||
#!/bin/sh
|
||||
# 构建管线:gitea push(main) → webhook → 本脚本 → dist rsync 到 www-staging
|
||||
# Phase 1:真实 astro build;webhook 侧 HMAC 验签仍留 Phase 4 实装(见 webhook-receive.sh)
|
||||
# 构建管线(Phase 5c 裸 clone 改造):构建源 = origin/main 硬跟,非本地工作树。
|
||||
#
|
||||
# 为什么:此前直接构建 ~/Code/Github/my-blog 工作树——分支/未提交状态会
|
||||
# 意外上线(Sveltia 冒烟期实测发生过);且 Sveltia 的 main 提交无法自动
|
||||
# 发布。改为独立构建仓 fetch+reset 硬跟 main:线上=远端 main,确定性闭环。
|
||||
# blog 仓已公开,匿名 fetch 无需凭据。
|
||||
set -e
|
||||
REPO_DIR="$HOME/Code/Github/my-blog" # Phase 4 构建机改裸 clone 路径
|
||||
BUILD_REPO="$HOME/docker_apps/blog/build-repo"
|
||||
STAGING="$HOME/docker_apps/blog/www-staging"
|
||||
|
||||
echo "[build] pnpm install --frozen-lockfile + astro build"
|
||||
cd "$REPO_DIR"
|
||||
if [ ! -d "$BUILD_REPO/.git" ]; then
|
||||
echo "[build] 首次克隆构建仓"
|
||||
git clone https://git.wait4x.online/wait4x/blog.git "$BUILD_REPO"
|
||||
fi
|
||||
|
||||
cd "$BUILD_REPO"
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
git clean -fd --exclude node_modules
|
||||
SHA=$(git rev-parse --short HEAD)
|
||||
echo "[build] 构建源: origin/main @ $SHA"
|
||||
|
||||
pnpm install --frozen-lockfile >/dev/null
|
||||
pnpm astro build
|
||||
|
||||
echo "[build] rsync -> $STAGING"
|
||||
mkdir -p "$STAGING"
|
||||
rsync -a --delete "$REPO_DIR/dist/" "$STAGING/"
|
||||
# 原图仓独立同步(不进 git/dist):/photos-originals/ 供图库"查看原图/下载"
|
||||
rsync -a --delete "$BUILD_REPO/dist/" "$STAGING/"
|
||||
ORIG="$HOME/docker_apps/blog/photos-originals"
|
||||
if [ -d "$ORIG" ]; then rsync -a "$ORIG/" "$STAGING/photos-originals/"; fi
|
||||
printf 'built at %s\n' "$(date -Is)" > "$STAGING/.build-stamp"
|
||||
echo "[build] done: $(find "$STAGING" -name '*.html' | wc -l) html files"
|
||||
printf 'built %s at %s\n' "$SHA" "$(date -Is)" > "$STAGING/.build-stamp"
|
||||
echo "[build] done: $(find "$STAGING" -name '*.html' | wc -l) html files @ $SHA"
|
||||
Reference in new issue
Block a user