@@ -15,19 +15,34 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Host runner (ubuntu-latest:host) does not load ~/.bashrc — nvm is invisible unless we
|
||||
# load it here. Persist PATH for all later steps (actions/setup-node, npm, etc.).
|
||||
- name: Put Node on PATH (NVM for host runner)
|
||||
# Host runner: no ~/.bashrc. Jobs may run as root while nvm lives under a normal user
|
||||
# (e.g. /home/azureuser/.nvm). Prefer system Node, then that user's nvm.
|
||||
- name: Put Node on PATH (host runner)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
||||
if [ ! -s "$NVM_DIR/nvm.sh" ]; then
|
||||
echo "NVM not found at $NVM_DIR/nvm.sh. Install nvm for the runner user or add Node to /usr/local/bin." >&2
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
echo "Using node already on PATH: $(command -v node)"
|
||||
echo "PATH=$PATH" >> "$GITHUB_ENV"
|
||||
node -v
|
||||
exit 0
|
||||
fi
|
||||
NVM_DIR_RESOLVED=""
|
||||
for dir in "${NVM_DIR:-}" "${HOME}/.nvm" "/home/azureuser/.nvm" "/home/ubuntu/.nvm"; do
|
||||
[ -z "$dir" ] && continue
|
||||
if [ -s "$dir/nvm.sh" ]; then
|
||||
NVM_DIR_RESOLVED="$dir"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$NVM_DIR_RESOLVED" ]; then
|
||||
echo "Node not found. Either symlink node to /usr/local/bin or install nvm under HOME," >&2
|
||||
echo "or under /home/azureuser/.nvm for this runner." >&2
|
||||
exit 1
|
||||
fi
|
||||
export NVM_DIR="$NVM_DIR_RESOLVED"
|
||||
# shellcheck source=/dev/null
|
||||
. "$NVM_DIR/nvm.sh"
|
||||
nvm use 20
|
||||
nvm use 20 2>/dev/null || nvm use default
|
||||
echo "PATH=$PATH" >> "$GITHUB_ENV"
|
||||
command -v node
|
||||
node -v
|
||||
|
||||
Reference in New Issue
Block a user