fix: upload/download-artifact 降级 v4 -> v3(v4 在 Gitea 上不被支持)
Deploy to Production / probe-network (push) Skipped
Deploy to Production / pre-check (push) Successful in 1m9s
Deploy to Production / build (push) Failing after 39m20s
Deploy to Production / deploy-edgeone (push) Skipped
Deploy to Production / finalize (push) Skipped
Deploy to Production / notify-failure (push) Successful in 5s

实测 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,最后才本地复算
This commit is contained in:
zqlit committed 2026-10-04 10:33:55 +08:00
1 parent fffdbe6865
commit ed38f9384b
1 file changed
+16 -7
+16 -7
View File
@@ -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/