Skip to content
M

CI/CD with GitHub Actions for Node.js Projects

Automate linting, type checks, tests and deployment on every push with a simple GitHub Actions workflow you can copy.

Md. Nazim Uddin

Updated Oct 25, 20262 min read0 views

Share
CI/CD with GitHub Actions for Node.js Projects
On this page

A pipeline that runs on every push catches broken code before it reaches users. GitHub Actions makes it almost free to set up.

A starter workflow

Create .github/workflows/ci.yml:

name: CI
on:
  push:
    branches: [main]
  pull_request:

jobs:
  check:
    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: npx tsc --noEmit
      - run: npm test --if-present
      - run: npm run build

Why each step matters

  • Lint keeps style consistent.
  • Type check catches whole categories of bugs.
  • Tests protect behavior.
  • Build proves the app can actually ship.

Cache dependencies

The cache: npm option reuses downloads between runs, cutting minutes to seconds.

Protect the main branch

Require the CI check to pass before merging a pull request. Nobody, including you, can then push broken code to production by accident.

Deploy automatically

Platforms like Vercel deploy on every push by themselves. For servers, add a job that runs after checks pass and uses a deploy key or an official action. Keep secrets in the repository settings, never in the workflow file.

Keep it fast

Slow pipelines get ignored. Run independent jobs in parallel and cache aggressively.

Takeaway

Lint, type check, test, build, then deploy. Automate the boring checks so reviews can focus on design.

Keep reading

NestJS REST API Best Practices That Scale
Backend
2 min read0

NestJS REST API Best Practices That Scale

Module boundaries, DTO validation, guards, exception filters and configuration: the NestJS structure that stays clean as your API grows.

NestJSTypeScriptNode.js
MNMd. Nazim UddinRead