chore(dependencies): update GitHub Actions and npm dependencies #780
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Node.js CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
lint: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 5 | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- run: npm ci | |
- name: Lint | |
run: npm run lint | |
build: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
exclude: | |
- os: windows-latest | |
node-version: 16.x | |
- os: windows-latest | |
node-version: 18.x | |
- os: macos-latest | |
node-version: 16.x | |
- os: macos-latest | |
node-version: 18.x | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "npm" | |
# Add Chrome installation - but only for Linux | |
- name: Install Chrome | |
if: runner.os == 'Linux' | |
run: | | |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' | |
sudo apt-get update | |
sudo apt-get install -y google-chrome-stable | |
- run: npm ci | |
- name: Build and Statically Render | |
shell: bash | |
run: | | |
# Create react-snap config | |
echo 'module.exports = { puppeteerArgs: ["--no-sandbox", "--disable-setuid-sandbox"] };' > react-snap.config.js | |
function retry { | |
local n=1 | |
local max=5 | |
local delay=1 | |
while true; do | |
"$@" && break || { | |
if [[ $n -lt $max ]]; then | |
((n++)) | |
echo "Command failed. Attempt $n/$max:" | |
sleep $delay; | |
else | |
echo "The command has failed after $n attempts." | |
return 1 | |
fi | |
} | |
done | |
} | |
retry npm run predeploy | |
env: | |
NODE_ENV: development | |
- name: Test | |
run: npm test | |
env: | |
NODE_ENV: development |