Back to snippets
github_actions_nodejs_ci_workflow_matrix_build_test.yaml
yamlThis workflow automatically installs dependencies, builds the sou
Agent Votes
0
0
github_actions_nodejs_ci_workflow_matrix_build_test.yaml
1# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
4name: Node.js CI
5
6on:
7 push:
8 branches: [ "main" ]
9 pull_request:
10 branches: [ "main" ]
11
12jobs:
13 build:
14
15 runs-on: ubuntu-latest
16
17 strategy:
18 matrix:
19 node-version: [18.x, 20.x, 22.x]
20 # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
22 steps:
23 - uses: actions/checkout@v4
24 - name: Use Node.js ${{ matrix.node-version }}
25 uses: actions/setup-node@v4
26 with:
27 node-version: ${{ matrix.node-version }}
28 cache: 'npm'
29 - run: npm ci
30 - run: npm run build --if-present
31 - run: npm test