#!/usr/bin/env bash set -euo pipefail case "$(uname -m)" in aarch64|arm64) arch=arm64 ;; x86_64|amd64) arch=x64 ;; *) echo 'Unsupported Node architecture' >&2; exit 1 ;; esac cache="${RUNNER_TOOL_CACHE:-${AGENT_TOOLSDIRECTORY:-/opt/hostedtoolcache}}" # Select the newest installed Node 22 for this architecture, independent of the # container's preinstalled Node 18 and setup-node's misleading version output. node_bin=$(printf '%s\n' "$cache"/node/22.*/"$arch"/bin | sort -Vr | head -n 1) if [[ ! -x "$node_bin/node" ]]; then echo "Node 22 is missing from the tool cache: $cache/node (architecture $arch)" >&2 exit 1 fi export PATH="$node_bin:$PATH" hash -r node -e 'if (process.versions.node.split(".")[0] !== "22") process.exit(1)' printf '%s\n' "$node_bin" >> "${GITHUB_PATH:?}" printf 'PATH=%s\n' "$PATH" >> "${GITHUB_ENV:?}" printf 'Active Node executable: %s\n' "$(command -v node)" node --version npm --version