From fffdbe686537c2e8abe3d64d03f0a61581b6b7a2 Mon Sep 17 00:00:00 2001 From: zqlit Date: Sun, 4 Oct 2026 10:06:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20artifact=20=E4=BC=A0=E9=80=92=E8=A1=A5?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E5=9D=91=EF=BC=88=E9=9A=90=E8=97=8F=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20+=20=E4=BA=A7=E7=89=A9=E5=B1=82=E6=95=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - upload-artifact@v4 默认排除隐藏文件,public/.build_hash 会丢 → 开 include-hidden-files: true,否则中转机读不到 hash 无法判断同步 - download 后产物可能多一层 public/ → EdgeOne 部署前统一拍平并校验 index.html 配合中转机 sync.sh 改造(COS → Gitea artifact),两者需同时生效。 --- .github/workflows/deploy.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c9735c7b..d9cac6cc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -224,10 +224,15 @@ jobs: # - deploy-edgeone 用 actions/download-artifact 直接拿(同 runner,零跨境) # - 国内中转机用 Gitea API 下载 artifact zip(替代原先的「从 COS 下载」) # hash 写在 public/.build_hash 里随 artifact 一起走,中转机解压后读它判断是否同步。 + # + # ★ include-hidden-files 必须为 true: + # upload-artifact@v4 默认「忽略隐藏文件」(以 . 开头),.build_hash 正好是隐藏 + # 文件,不开这个开关它不会进 artifact,中转机就读不到 hash、无法判断是否需要同步。 uses: actions/upload-artifact@v4 with: name: hugo-public path: public/ + include-hidden-files: true retention-days: 7 - name: Report deploy status (built) @@ -423,6 +428,25 @@ jobs: name: hugo-public path: public/ + - name: Normalize artifact layout + # upload-artifact 对「目录路径」的打包语义存在版本/实现差异: + # 解出来的可能是 public/index.html(内容直接在根),也可能是 + # public/public/index.html(多一层目录)。这里统一拍平成 public/index.html, + # 免得 EdgeOne 部署时找不到入口、或站点多出一层 /public/ 前缀。 + run: | + if [ ! -f public/index.html ] && [ -f public/public/index.html ]; then + echo "ℹ️ 检测到产物多一层 public/,已拍平" + mv public/public public__flat + rm -rf public + mv public__flat public + fi + if [ ! -f public/index.html ]; then + echo "❌ 产物结构异常:public/index.html 不存在" + find public -maxdepth 2 | head -20 + exit 1 + fi + echo "✅ public/index.html 就位,文件数 $(find public -type f | wc -l)" + - name: Start upload timing id: start-edgeone-upload run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT