From 27260ee85e3af38b36641bb3da9b42169c3aec5c Mon Sep 17 00:00:00 2001 From: Adam French Date: Fri, 27 Nov 2026 13:50:07 +0000 Subject: [PATCH] Install node for host-mode JavaScript actions In host mode the runner runs actions/checkout and friends with the host's node, and stpbuild had none: salary-insights' first run there failed with 'Cannot find: node in PATH'. RUNNER_NODE_VERSION in a host file installs that release from nodejs.org (sha256 from SHASUMS256.txt) as /usr/local/bin/node. stpbuild pins Node 24, the actions' runtime; Renovate bumps it within the major. Co-Authored-By: Claude Opus 5.5 --- README.md | 7 ++++++- hosts/stpbuild.env | 2 ++ install.sh | 25 +++++++++++++++++++++++++ renovate.json5 | 14 ++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cdae3b..c5a3b01 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,12 @@ registration turns it into `/var/lib/gitea-runner/.runner`, which is the lasting credential. Gitea's runner list then shows the new runner. The VM needs `curl`, `git` and, for container or host jobs that use it, -Docker with `RUNNER_USER` in the `docker` group. A VM without Tailscale can +Docker with `RUNNER_USER` in the `docker` group. Host-mode jobs that use +JavaScript actions (`actions/checkout`, `actions/setup-node`, …) also need +`node` on the host, or they fail with `Cannot find: node in PATH`: set +`RUNNER_NODE_VERSION` in the host file and `install.sh` puts that release at +`/usr/local/bin/node` (only `node`; jobs get their own Node from +`actions/setup-node`). A VM without Tailscale can still be set up from the Proxmox host: `qm guest exec -- bash -c '...'`. ## Upgrading diff --git a/hosts/stpbuild.env b/hosts/stpbuild.env index 0e28a11..87093cc 100644 --- a/hosts/stpbuild.env +++ b/hosts/stpbuild.env @@ -6,3 +6,5 @@ RUNNER_NAME=stpbuild-runner RUNNER_USER=adamf RUNNER_CAPACITY=2 RUNNER_LABELS="build:host" +# For JavaScript actions in host jobs (actions/checkout@v5 is node24). +RUNNER_NODE_VERSION=24.22.3 diff --git a/install.sh b/install.sh index 0f4b4dd..cbb7b81 100755 --- a/install.sh +++ b/install.sh @@ -68,6 +68,31 @@ if [ "$current" != "v${VERSION}" ]; then changed=1 fi +# --- node (host-mode JavaScript actions) ------------------------------------- +# In host mode the runner runs actions such as actions/checkout with the +# host's `node`. Only `node` goes on PATH: the job's own Node comes from +# actions/setup-node. +if [ -n "${RUNNER_NODE_VERSION:-}" ]; then + nv="v${RUNNER_NODE_VERSION}" + if [ "$(/usr/local/bin/node --version 2>/dev/null || true)" != "$nv" ]; then + case "$(uname -m)" in + x86_64) narch=x64 ;; aarch64) narch=arm64 ;; armv7l) narch=armv7l ;; + *) die "no Node build for $(uname -m)" ;; + esac + echo "Installing node ${nv} for host-mode actions" + ntmp=$(mktemp -d) + tarball="node-${nv}-linux-${narch}.tar.gz" + curl -fsSL "https://nodejs.org/dist/${nv}/${tarball}" -o "$ntmp/$tarball" + curl -fsSL "https://nodejs.org/dist/${nv}/SHASUMS256.txt" -o "$ntmp/SHASUMS256.txt" + (cd "$ntmp" && grep " ${tarball}\$" SHASUMS256.txt | sha256sum -c --quiet -) + rm -rf "/opt/node-${nv}" + mkdir -p "/opt/node-${nv}" + tar -xzf "$ntmp/$tarball" -C "/opt/node-${nv}" --strip-components=1 --no-same-owner + ln -sfn "/opt/node-${nv}/bin/node" /usr/local/bin/node + rm -rf "$ntmp" + fi +fi + # --- config ------------------------------------------------------------------ # State (config.yaml and the .runner credential) lives outside this checkout, # so a git clean or re-clone never loses the registration. diff --git a/renovate.json5 b/renovate.json5 index 960b450..b131579 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -19,6 +19,14 @@ registryUrlTemplate: "https://gitea.com", extractVersionTemplate: "^v(?.+)$", }, + { + // The host `node` that runs JavaScript actions in host-mode jobs. + customType: "regex", + managerFilePatterns: ["/^hosts/[^/]+\\.env$/"], + matchStrings: ["RUNNER_NODE_VERSION=(?[0-9][\\w.-]*)"], + depNameTemplate: "node", + datasourceTemplate: "node-version", + }, ], packageRules: [ @@ -29,5 +37,11 @@ matchUpdateTypes: ["major"], prBodyNotes: ["Major release: check the minimum Gitea version in the release notes against stpgit before merging."], }, + // Stay on the major that actions declare (`runs.using: node24`); move by hand. + { + matchDepNames: ["node"], + matchUpdateTypes: ["major"], + enabled: false, + }, ], }