Skip to content

No. 35DevOps9 min read2,456 words

CI/CD for small teams: a pipeline you can actually maintain

A CI/CD setup for teams of two to five: one fast GitHub Actions workflow, deploy on green, safe migrations, and the few guardrails that stop it rotting.

Written by
Lazy Devs
Published
Updated
Sources
Cited inline

Key takeaways · 05

The short version

  1. 01A small team's CI only needs to prove four things: the code compiles, the tests pass, the deployed artifact is the one you tested, and deploys take one click or none.
  2. 02Keep one workflow file, order steps cheapest-first (typecheck and lint before database tests and build), and hold pull request runs under a budget such as five minutes.
  3. 03A concurrency group that cancels superseded runs on feature branches is the cheapest reliability win in GitHub Actions; leave main uncancelled so deploys finish.
  4. 04Never drop or rename a database column in the same deploy that stops using it. Expand first, migrate data, and contract in a later deploy.
  5. 05Add staging environments, monorepo orchestrators, custom runners and coverage gates only when a specific, measurable pain demands them.
On this page · 10

A small team's CI/CD pipeline should do four things: prove the code compiles, prove the tests pass, deploy the exact build it verified, and make deploying a one-click (or zero-click) event. Everything beyond that is optional until a specific pain demands it. The pipeline that survives is one short, fast workflow file that any developer on the team can read in five minutes and fix without a meeting.

Most CI/CD advice is written for companies with a platform team. You are not that company. You are three people shipping a Next.js app, and the pipeline you copied from a conference talk now takes eleven minutes, flakes twice a week, and nobody remembers how the deploy step works. This is the boring version that keeps working, and it is the same shape we set up when we take over a project with no pipeline.

What CI/CD actually needs to do for a small team

Continuous integration means every change gets merged often and verified automatically. Continuous delivery means the verified build can go to production without anyone hand-assembling it. Martin Fowler's long-standing description of CI still holds up: integrate frequently, keep the build fast, and fix a broken build before doing anything else.

Translated into requirements for a team of two to five, that is four things and nothing else:

  1. The code compiles and type-checks.
  2. The tests pass, against real dependencies where it matters.
  3. The thing you deploy is the thing you tested.
  4. Deploys are one click, or zero clicks.

Notice what is missing: matrix builds across five Node versions, a custom container registry, blue-green orchestration, a chat bot that posts a haiku on every merge. Those are real tools, but each one is a thing that breaks and that someone has to own. When you are small, every piece of infrastructure is a tax paid by whoever is on call. Add it only when the pain of not having it is louder than the pain of maintaining it.

The rule that prevents most rot

One workflow file. Maybe two. If your .github/workflows directory has more files than your team has people, you have a problem that will compound. Pipelines rot because they grow features nobody removes. Keep the surface small enough that a single person can hold it in their head, and delete any step the team has stopped trusting.

A complete GitHub Actions workflow you can paste in

Here is a full workflow for a typical Next.js and TypeScript app with a Postgres-backed test suite. It runs on pull requests and on pushes to main. It is the whole thing, not a fragment.

name: ci
 
on:
  push:
    branches: [main]
  pull_request:
 
# Read-only token by default; grant more per job only if needed.
permissions:
  contents: read
 
concurrency:
  group: ci-${{ github.ref }}
  # Cancel superseded runs on branches, but let main finish.
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
 
jobs:
  verify:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    services:
      postgres:
        image: postgres:18
        env:
          POSTGRES_PASSWORD: postgres
          POSTGRES_DB: app_test
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 5s
          --health-timeout 5s
          --health-retries 5
    env:
      DATABASE_URL: postgres://postgres:postgres@localhost:5432/app_test
    steps:
      - uses: actions/checkout@v7
 
      - uses: actions/setup-node@v7
        with:
          node-version: 24
          cache: npm
 
      - name: Restore Next.js build cache
        uses: actions/cache@v6
        with:
          path: .next/cache
          key: nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-${{ github.sha }}
          restore-keys: |
            nextjs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}-
 
      - run: npm ci
 
      - name: Typecheck
        run: npm run typecheck
 
      - name: Lint
        run: npm run lint
 
      - name: Migrate test database
        run: npm run db:migrate
 
      - name: Test
        run: npm test
 
      - name: Build
        run: npm run build

Every line in there is deliberate, so here is the reasoning.

The concurrency block cancels older runs when you push again to the same branch. Without it, a busy pull request queues up five stale runs that burn minutes and confuse everyone about which one matters. The conditional keeps runs on main from being cancelled, so a quick follow-up merge never kills a deploy halfway through. GitHub documents the options in its workflow concurrency guide.

The Postgres service container runs a real database instead of a mock. Your migrations and SQL get tested against the engine you ship on, at the same major version. GitHub's guide to Postgres service containers covers the health-check options, which matter: without them, your tests can start before the database accepts connections.

npm ci instead of npm install. npm ci installs exactly what is in your lockfile and fails if package.json and the lockfile disagree. That is the behaviour you want in CI: reproducible, not clever.

The Next.js build cache persists .next/cache between runs, which the Next.js CI build caching guide recommends for every CI provider. Without it, every build starts cold.

Least-privilege permissions and a timeout. The permissions block makes the default token read-only, and timeout-minutes stops a hung test from eating hours of runner time (the default job timeout is six hours). Least-privilege tokens are a core recommendation in GitHub's secure use reference for Actions, which also recommends pinning third-party actions to a full commit SHA.

The steps run cheapest-first. Typecheck and lint fail in seconds. There is no reason to boot a database and run a full build only to discover someone left an unused import that trips the linter. One Next.js 16 note: next lint was removed and next build no longer lints, so your lint script should call ESLint (or Biome) directly.

How to keep the pipeline fast

Speed is not vanity here. A slow pipeline trains people to stop watching it, and a pipeline nobody watches is quietly broken.

HabitWhat it buys youWhen to bother
Cache dependencies (cache: npm)Skips re-downloading packages on every runAlways, it is one line
Cache .next/cacheIncremental Next.js builds instead of cold onesAs soon as builds pass a minute
Order steps cheapest-firstTypos fail in seconds, not minutesAlways
Cancel superseded runsNo queue of stale runs on busy branchesAlways
Split into parallel jobsShorter wall-clock timeOnly when measured; each job pays checkout and install again
Shard the test suiteLarge suites finish in a fraction of the timeWhen tests alone exceed your budget

Set a time budget and enforce it

Pick a number. For a project this size, under five minutes on a pull request is a reasonable line. When you cross it, that is a signal to investigate, not a reason to shrug. The budget is what keeps the pipeline honest as the codebase grows.

Kill flaky tests on sight

One flaky test does more damage than ten missing ones, because it teaches the team to re-run red builds out of habit. When a re-run turns a failure green, that is not luck. It is a bug you have not found yet, often a race condition, a shared test fixture or a dependency on wall-clock time. Quarantine it or fix it the same week. Our testing strategy that actually pays off covers which tests are worth having in the first place, which is the other half of a fast suite.

Deploy on green: boring is the feature

For most small teams on Vercel, Netlify or a similar platform, the best deploy pipeline is the one the platform already gives you. Push to main, it builds, it goes live. Every pull request gets a preview deployment with its own URL. You did not write that pipeline, so you do not maintain it, and that is the whole point.

If you self-host, ship the artifact you tested

If you deploy to your own servers or containers, the deploy must be triggered by the same green run that tested the code, and it must ship the same artifact. A common failure mode is testing one commit and then deploying a fresh build of main that happens to include a change merged a minute later. Build once, tag the artifact with the commit SHA, and promote that exact artifact. If you package the app as a container, our guide to Docker for web apps without the overkill shows a lean multi-stage image that works well for this.

Protect main so green actually means something

Turn on branch protection for main and mark the verify job as a required status check. Without that, CI is advice rather than a gate, and someone in a hurry will eventually merge a red build. Requiring one approving review is reasonable for most teams of three or more. For a team of two, a required green check alone is often enough.

Make rollback a button, not a project

Every deploy will eventually go wrong. On managed platforms, rolling back is usually promoting the previous deployment. When self-hosting, keep the last few tagged images around and make redeploying one of them a single command. Practise it once before you need it. A rollback you have never run is a theory.

Database migrations without the 2 a.m. incident

Database migrations are where small-team CI/CD goes from boring to scary. During any rolling deploy there is a window where old and new versions of your code run at the same time against the same database. Every migration has to be safe for both.

The pattern that saves you is usually called expand and contract. Never drop or rename a column in the same deploy that stops using it. Split it across deploys:

-- Deploy 1 (expand): add the new column. Old code ignores it.
ALTER TABLE users ADD COLUMN email_normalized text;
 
-- Deploy 2: new code writes BOTH columns on every insert and update.
 
-- Then a separate, idempotent backfill for older rows. Safe to re-run.
UPDATE users
SET email_normalized = lower(email)
WHERE email_normalized IS NULL;
 
-- Deploy 3: code reads only email_normalized.
 
-- Deploy 4 (contract), once no running code reads the old column:
-- ALTER TABLE users DROP COLUMN email;

The backfill runs after the dual-write deploy on purpose: if it ran first, any row written by old code between the backfill and the deploy would be left empty. The old code reads the old column, the new code reads the new one, and at no point does a running process hit a column that does not exist. It is slower than doing it all at once, which is exactly why it works.

A few related habits:

  • Run migrations as their own step, before the new code takes traffic, and fail the deploy if a migration fails.
  • Watch for locking statements. Some ALTER TABLE forms rewrite the whole table or hold heavy locks. On a large table, build indexes with CREATE INDEX CONCURRENTLY and backfill in batches.
  • Make backfills idempotent, so a retry after a timeout does not double-apply anything.
  • Decouple risky releases from deploys. Ship the code dark and switch it on separately. Our guide to feature flags without a platform shows how to do that with a single Postgres table.

Secrets, dependencies and the slow drift

The pipeline you set up today will slowly decay unless something keeps it current. Three low-effort habits prevent most of that.

Keep secrets out of the repo and out of logs. Store them as repository or environment secrets, scope production credentials to a protected environment, and prefer short-lived credentials via OIDC over long-lived cloud keys where your provider supports it.

Let a bot update dependencies. Dependabot version updates can open pull requests for npm packages and for the GitHub Actions themselves. Batch them weekly so they do not drown the team, and let CI decide whether they are safe.

Know whether your pipeline is helping. The DORA research program now tracks five software delivery measures: change lead time, deployment frequency, failed deployment recovery time, change fail rate and deployment rework rate. It started with four and added rework rate later. You do not need a dashboard for them. You only need to notice when deploys get rarer, slower or scarier, because that is when the pipeline needs attention.

What to skip until you are bigger

Resist these until something concretely hurts:

Tool or practiceAdd it when
Monorepo build orchestratorBuilds are slow because unchanged packages rebuild every time
Staging environmentYou need a stable place for partner sandboxes or manual QA sign-off
Custom or self-hosted runnersYour bill or queue times say hosted runners no longer fit
High coverage gatesThe codebase is mature and coverage drops signal real gaps
Multi-environment promotion pipelinesCompliance or customers require a formal release process

On coverage specifically: a high percentage requirement on a young codebase mostly produces tests written to satisfy the number. Track coverage, do not gate on it yet.

If you are weighing a monorepo, our pragmatic monorepo guide explains when affected-package detection and remote caching earn their place. Every item in that table is correct at some scale. None of them is correct on day one, and adding them early is how a three-person team ends up with a pipeline that needs a fourth person to babysit.

The order we set it up in

When we take over a project with no pipeline, or with one nobody trusts, this is the sequence we follow:

  1. Get the build, typecheck, lint and test steps green locally with one command each.
  2. Add the single workflow above, with a real database service and a concurrency group.
  3. Protect main and make the CI job a required check.
  4. Connect deploys to green builds on main, with preview deployments for pull requests.
  5. Write the next migration in expand-and-contract style, and practise one rollback.
  6. Turn on Dependabot and set a time budget for the pipeline.

After that, the pipeline only changes when something measurable forces it to. Pair it with basic observability for production web apps so you find out about a bad deploy from a graph rather than a customer.

A pipeline you will still trust next year

Good CI/CD for a small team is a short, fast, single workflow that proves the code compiles and the tests pass, deploys the exact build it verified, and treats migrations with respect. Add complexity only when a specific pain demands it, and delete anything the team has stopped trusting.

If your pipeline has started to rot, or you are starting fresh and want it right from the first commit, talk to us. Setting up delivery pipelines small teams can own is a core part of our cloud and DevOps practice.

Feature flags make continuous delivery safer; we compare LaunchDarkly, PostHog, GrowthBook and others in the best feature flag tools in 2026.

FAQ · 05 questions

Frequently asked questions

What is the difference between CI and CD?

Continuous integration (CI) means every change is merged often and automatically verified by building and testing it. Continuous delivery or deployment (CD) means the verified build can be released, or is released automatically, without manual packaging steps. For a small team, CI is the safety net and CD is the habit of shipping the exact build that passed.

How long should a CI pipeline take for a small team?

Aim for under five minutes on a pull request for a typical web app. Past that point, people stop watching the run and start context switching, which is how broken builds get merged. Treat crossing your budget as a bug to investigate, not a fact of life.

Do small teams need a staging environment?

Usually not at first. Per-pull-request preview deployments plus production cover most small products, and a long-lived staging environment tends to drift from production and fill up with stale data. Add one when you have a concrete need, such as testing against a partner's sandbox or a manual QA sign-off.

Should CI run tests against a real database or a mock?

Use a real database of the same engine and major version you run in production. GitHub Actions service containers make a throwaway Postgres instance a few lines of YAML. A mocked database only proves that your mock behaves, not that your migrations and queries work.

How do you run database migrations safely in CI/CD?

Run migrations as an explicit, ordered step before the new code receives traffic, and write every migration so old and new code can both run against the schema at the same time. Additive changes ship first, data is backfilled separately, and destructive changes such as dropping a column wait for a later deploy.

Related service

Cloud & DevOps

Reliable deploys and infrastructure that gets out of the way.

Learn more

Next step

Want this built right?

This is the work we do every day. Tell us what you are building and we will show you exactly how we would ship it.

First reply
Within 1 business day
Typical start
1–2 weeks
Pricing
Fixed price per phase
You own
All code and accounts