Install dependencies, lint, test, and build a Node project.

Section: Testing and build pipelines

Node.js CI workflow

yaml
yaml
name: Node CI

on:
  push:
    branches: [main]
  pull_request:

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm run lint
      - run: npm test -- --ci
      - run: npm run build
Explanation

This is a solid baseline CI workflow for Node-based apps and libraries.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Testing and build pipelines
Python CI workflow
Set up Python, install dependencies, and run tests.
OpenIn sheetyamlsame section
Build a Docker image
Use Buildx for modern Docker builds.
OpenIn sheetyamlsame section
Create a GitHub release on tag push
Publish a release whenever a version tag is pushed.
Publish an npm package
Publish to npm from GitHub Actions.
Deploy only from main after tests
Gate deployments on successful CI from the main branch.