Setting Up a Fast GitHub Actions CI Pipeline for Next.js & Node
September 10, 2026 · 6 min read
Relying on developers remembering to run `npm run build` locally before pushing eventually breaks `main`. A tiny GitHub Actions workflow catches broken imports, lint errors, and failing tests on every pull request.
A minimal, fast CI workflow
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run lint
- run: npm run buildEnabling `cache: npm` with `npm ci` cuts install time dramatically and ensures CI installs the exact versions locked in `package-lock.json`.