ci: 共享 pnpm store 加速本地 runner

This commit is contained in:
que01 committed 2026-10-23 16:09:25 +08:00
1 parent b43b6f2785
commit b82aa12875
4 files changed
+24 -11

No files matched your search

+9 -1
View File
@@ -15,6 +15,7 @@
# RUNNER_ROOT 默认 $HOME/gitea-runner
# RUNNER_CAPACITY 默认 1,按 runner 主机资源设置并发数
# RUNNER_CONTAINER_OPTIONS 默认 "--cpus=1.5 --memory=4g"
# RUNNER_PNPM_STORE 宿主机 pnpm store 目录,默认 $RUNNER_ROOT/pnpm-store
# RUNNER_IMAGE 任务容器镜像,默认 node:24-bookworm;本地预构建镜像可传 personal-brand-ci:node24
# CACHE_PORT 默认 8193
# RUNNER_CACHE_HOST 默认 172.17.0.1(Docker 默认 bridge 网关)
@@ -29,6 +30,7 @@ RUNNER_VERSION=${RUNNER_VERSION:-5.2.0}
RUNNER_ROOT=${RUNNER_ROOT:-$HOME/gitea-runner}
RUNNER_CAPACITY=${RUNNER_CAPACITY:-1}
RUNNER_CONTAINER_OPTIONS=${RUNNER_CONTAINER_OPTIONS:-"--cpus=1.5 --memory=4g"}
RUNNER_PNPM_STORE=${RUNNER_PNPM_STORE:-$RUNNER_ROOT/pnpm-store}
RUNNER_IMAGE=${RUNNER_IMAGE:-node:24-bookworm}
CACHE_PORT=${CACHE_PORT:-8193}
RUNNER_CACHE_HOST=${RUNNER_CACHE_HOST:-172.17.0.1}
@@ -58,7 +60,7 @@ run() {
archive="gitea-runner-${RUNNER_VERSION}-linux-${ARCH}.xz"
base="https://dl.gitea.com/gitea-runner/${RUNNER_VERSION}"
run mkdir -p "$RUNNER_ROOT" "$CACHE_DIR"
run mkdir -p "$RUNNER_ROOT" "$CACHE_DIR" "$RUNNER_PNPM_STORE"
if [ ! -x "$RUNNER_ROOT/gitea-runner-${RUNNER_VERSION}-linux-${ARCH}" ]; then
run curl -fsSL -o "$RUNNER_ROOT/$archive" "$base/$archive"
run curl -fsSL -o "$RUNNER_ROOT/$archive.sha256" "$base/$archive.sha256"
@@ -66,6 +68,12 @@ if [ ! -x "$RUNNER_ROOT/gitea-runner-${RUNNER_VERSION}-linux-${ARCH}" ]; then
run xz -d -f "$RUNNER_ROOT/$archive"
fi
run chmod +x "$RUNNER_ROOT/gitea-runner-${RUNNER_VERSION}-linux-${ARCH}"
# 把 pnpm store 挂到所有任务容器的固定路径;workflow 通过 npm_config_store_dir 指向它。
case " $RUNNER_CONTAINER_OPTIONS " in
*"/workspace/.pnpm-store"*) ;;
*) RUNNER_CONTAINER_OPTIONS="$RUNNER_CONTAINER_OPTIONS --volume=${RUNNER_PNPM_STORE}:/workspace/.pnpm-store" ;;
esac
run ln -sf "gitea-runner-${RUNNER_VERSION}-linux-${ARCH}" "$RUNNER_ROOT/gitea-runner"
label_specs() {