Skip to content

6. A Real CI Pipeline: Lint, Build, Scan, Sign, Push

Every push and PR now runs lint and tests on both Node projects, builds Docker images for backend and frontend, scans them with Trivy for critical/high vulnerabilities, pushes to GitHub Container Registry, and signs the published images with Cosign using GitHub’s own OIDC token — no long-lived signing keys sitting in repo secrets. Four jobs: lint-test-backend, lint-test-frontend, and two image jobs gated behind the lint jobs passing first.

Permissions are scoped explicitly at the workflow level rather than left at GitHub’s default — contents: read, packages: write, id-token: write for Cosign’s keyless signing. Never contents: write on a workflow that only builds and pushes images; that’s how a compromised third-party Action ends up rewriting your repo instead of just your registry.

Bug one: strict JSON doesn’t forgive a missing comma

Section titled “Bug one: strict JSON doesn’t forgive a missing comma”

Adding a lint script to frontend/package.json broke npm ci on the very first CI run — EJSONPARSE, “Expected ‘,’ or ‘}’”. package.json is strict JSON, and the line above the new one was missing its trailing comma. An easy typo to make by hand in vim, and one worth verifying locally before pushing: node -e "console.log(JSON.parse(require('fs').readFileSync('package.json')))" catches it in a second, no CI round-trip required.

Bug two: SARIF upload needs a feature this repo doesn’t have

Section titled “Bug two: SARIF upload needs a feature this repo doesn’t have”

The backend image job failed with Resource not accessible by integration on the Trivy SARIF upload step. That step pushes scan results into GitHub’s Code Scanning UI — which requires GitHub Advanced Security, a paid feature on private repos (public repos get it free). Fix was dropping the upload step and switching Trivy’s output from sarif to table, so results still print in the job log for visibility without trying to upload anywhere they can’t go. security-events: write came off the permissions block too, since nothing needed it anymore.

Bug three: ESLint doing exactly what it’s supposed to

Section titled “Bug three: ESLint doing exactly what it’s supposed to”

Once the JSON and SARIF issues cleared, ESLint failed the frontend job for real — 13 errors, 10 of them 'React' is defined but never used. Modern React’s JSX transform doesn’t need import React from 'react' in every file anymore, but the codebase still had it everywhere from older conventions. Stripped with a grep/sed sweep across the flagged files — except one: main.jsx genuinely used React.StrictMode, so removing its import broke the build, and it had to go back in. The remaining three (a dead catch binding, an unused navigate variable, and a missing error-display block in Cart.jsx) were each a real, small fix rather than noise to silence.

None of these three bugs were exotic — a missing comma, a paid-feature gate, and a linter correctly catching stale imports. What actually mattered was treating each CI failure as a real signal worth reading the actual error for, rather than reflexively adding continue-on-error or disabling the check. That’s the same instinct that makes CI worth having in the first place: a pipeline that’s allowed to go green while ignoring its own errors isn’t protecting anything.

A 10-150 person team typically runs one CI workflow per service family, pins third-party Actions to commit SHAs for anything touching secrets or OIDC, and keeps build workflows separate from release workflows triggered by tags. The failure mode that shows up constantly isn’t a missing feature — it’s permission sprawl (contents: write added once to fix a release bot, never removed) or a scan step that uploads results nobody’s gating on. Cosign keyless signing is common enough now that skipping it is a conscious risk decision, not an oversight.


Next: Lesson 7, CI Developer Experience.