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 <[email protected]>
This commit is contained in:
+25
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user