Build the frontend once per pipeline and reuse it in the dev backend image [CI]
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/verify Pipeline was canceled
ci/woodpecker/push/dev-image Pipeline was canceled

This commit is contained in:
justme committed 2026-10-21 15:17:37 +08:00
1 parent 3654d37da5
commit d1ece67a6a
5 files changed
+82 -6

No files matched your search

+4 -1
View File
@@ -11,7 +11,8 @@ dirs=(node_modules display/node_modules admin/node_modules)
mkdir -p "$cache"
exec 9> "$cache/.lock"
key="$(cat "$web/package-lock.json" "$web/package.json" "$web/display/package.json" "$web/admin/package.json" | sha256sum | cut -c1-16)"
# 开发构建会把版本号写进 package.json;缓存键里去掉 version 行,否则每个提交都是新的键,缓存永远命中不了
key="$(cat "$web/package-lock.json" "$web/package.json" "$web/display/package.json" "$web/admin/package.json" | grep -v '^ "version":' | sha256sum | cut -c1-16)"
restore() {
[[ -d "$cache/$key/node_modules" ]] || return 1
@@ -57,3 +58,5 @@ failed=0
for pid in "${pids[@]}"; do wait "$pid" || failed=1; done
[[ "$failed" == 0 ]] || { echo "web build failed" >&2; exit 1; }
[[ -n "${WEB_SKIP_LINT:-}" ]] || npm run lint:css --prefix "$web"
# 开发构建(main 上带 [CI] 的提交):前端是这条流水线的唯一一份,放进共享目录,开发镜像的 Backend 直接用(见 ci/shared-web.sh)
[[ -z "${WEB_PUBLISH_SHARED:-}" ]] || bash "$root/ci/shared-web.sh" publish