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