ci: updated workflow

This commit is contained in:
Marvin Zhang
2024-11-22 20:51:56 +08:00
parent bfd2e214f2
commit 9df54c18a7
4 changed files with 37 additions and 33 deletions

View File

@@ -2,39 +2,33 @@
version="22"
# installs nvm (Node Version Manager)
# Install nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
# add nvm to path
# Add nvm to path
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> ~/.bashrc
# ensure changes take effect immediately
# Ensure changes take effect immediately
export NVM_DIR="$HOME/.nvm"
[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[[ -s "$NVM_DIR/bash_completion" ]] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# download and install Node.js (you may need to restart the terminal)
# Download and install Node.js (you may need to restart the terminal)
nvm install ${version}
# set node version and make it the default
# Set node version and make it the default
nvm use ${version}
nvm alias default ${version}
# Create symbolic links
ln -sf "$(nvm which node)" /usr/local/bin/node
ln -sf "$(nvm which npm)" /usr/local/bin/npm
ln -sf "$(nvm which yarn)" /usr/local/bin/yarn
ln -sf "$(nvm which pnpm)" /usr/local/bin/pnpm
# verifies the right Node.js version is in the environment
# Verify the right Node.js version is in the environment
if [[ ! "$(node -v)" =~ ^v${version} ]]; then
echo "Node.js version is not v${version}.x"
exit 1
fi
# install node dependencies
# Install node dependencies
npm install -g \
npm@latest \
yarn \
@@ -45,6 +39,12 @@ npm install -g \
playwright-chromium \
crawlee
# Create symbolic links
ln -sf "$(nvm which node)" /usr/local/bin/node
ln -sf "$(nvm which npm)" /usr/local/bin/npm
ln -sf "$(nvm which yarn)" /usr/local/bin/yarn
ln -sf "$(nvm which pnpm)" /usr/local/bin/pnpm
# Clean up
npm cache clean --force && \
rm -rf ~/.npm