From ed38f9384b872969e041b8e053663b8af3e69b74 Mon Sep 17 00:00:00 2001 From: zqlit Date: Sun, 4 Oct 2026 10:33:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20upload/download-artifact=20=E9=99=8D?= =?UTF-8?q?=E7=BA=A7=20v4=20->=20v3=EF=BC=88v4=20=E5=9C=A8=20Gitea=20?= =?UTF-8?q?=E4=B8=8A=E4=B8=8D=E8=A2=AB=E6=94=AF=E6=8C=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实测 run #55:build job 在「Upload build artifact (public/)」失败: ::error::@actions/artifact v2.0.0+, upload-artifact@v4+ and download-artifact@v4+ are not currently supported on GHES. Gitea 被 v4 识别为 GHES、未实现新 artifact API → 降回 v3(走旧 API)。 v3 无 include-hidden-files 选项、隐藏文件不保证进包,故: - build job 额外写非隐藏的 public/build_hash.txt 兜底 - 中转机 sync.sh 优先读 .build_hash,读不到退 build_hash.txt,最后才本地复算 --- .github/workflows/deploy.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d9cac6cc..97011cae 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -209,7 +209,14 @@ jobs: run: | BUILD_HASH=$(find public -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | awk '{print $1}') echo "build_hash=${BUILD_HASH}" >> $GITHUB_OUTPUT + # 写两份: + # .build_hash —— 历史沿用(也用于 upx put 到又拍云 /__build_hash) + # build_hash.txt —— 非隐藏。upload-artifact(v3/v4)对「以 . 开头的隐藏 + # 文件」处理不一致,可能整个丢掉,非隐藏文件才稳。 + # 中转机优先读 .build_hash,读不到退到 build_hash.txt,都没有才本地复算。 + # 注意:本步的 find 在写这两个文件之前执行,所以 hash 不含它们自身。 echo "$BUILD_HASH" > public/.build_hash + echo "$BUILD_HASH" > public/build_hash.txt - name: Build statistics id: stats @@ -223,16 +230,17 @@ jobs: # 2026-10-04 起产物不再上传腾讯云 COS,改用 Gitea artifact 传递: # - 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 + # ★ 必须用 v3,不能用 v4:实测 v4 在 Gitea 上直接失败 —— + # "@actions/artifact v2.0.0+, upload-artifact@v4+ and download-artifact@v4+ + # are not currently supported on GHES."(Gitea 被识别为 GHES,未实现新版 + # artifact 服务)。v3 走的是 Gitea 已实现的旧 artifact API。 + # v3 也没有 include-hidden-files 选项;隐藏文件能不能进 artifact 不可靠, + # 所以 hash 另外写了一份非隐藏的 public/build_hash.txt 兜底。 + uses: actions/upload-artifact@v3 with: name: hugo-public path: public/ - include-hidden-files: true retention-days: 7 - name: Report deploy status (built) @@ -423,7 +431,8 @@ jobs: - name: Download build artifact id: download-files # 从 Gitea artifact 下载 public/(build job 上传的,同 runner 零跨境、零费用) - uses: actions/download-artifact@v4 + # ★ 必须与上传端同为 v3:v4 在 Gitea(被识别为 GHES)上不受支持。 + uses: actions/download-artifact@v3 with: name: hugo-public path: public/