What this free workflow includes
Node 20 + 22 matrix
Catch version-specific problems before deploy.
Catch version-specific problems before deploy.
npm dependency cache
Faster CI runs with setup-node caching.
Faster CI runs with setup-node caching.
Safe optional commands
Lint, typecheck, tests, and build run only when configured.
Lint, typecheck, tests, and build run only when configured.
Copy this into .github/workflows/nodejs-ci.yml
name: Node.js CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
name: Test on Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [20, 22]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Run lint if configured
run: npm run lint --if-present
- name: Run typecheck if configured
run: npm run typecheck --if-present
- name: Run tests
run: npm test --if-present
- name: Build project
run: npm run build --if-present
Need more than Node CI?
The paid GitHub Actions Workflow Templates Pack includes 10 templates: Docker build + push, Vercel deploy, Python CI, GitHub Pages deploy, release automation, security scans, SSH deploy, database backup, monorepo CI, and this Node workflow.