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