Skip to content
Latchkey

Running Newman and Postman Collections in GitHub Actions

Run your Postman collections in CI with Newman to test APIs on every change.

Newman is the CLI runner for Postman collections. In CI you export the collection and environment as JSON, run newman against them, and optionally emit JUnit for reporting. It is a quick way to turn existing Postman tests into a CI gate.

What you need

  • An exported collection JSON (and optional environment JSON).
  • Newman, installed via npm or the postman/newman Docker image.
  • A reachable API target.

The workflow

Install Newman and run the collection with an environment.

.github/workflows/api-tests.yml
- uses: actions/setup-node@v4
  with:
    node-version: 20
- run: npm install -g newman
- run: newman run ./postman/collection.json -e ./postman/staging.json --reporters cli,junit --reporter-junit-export results.xml

Common gotchas

  • Secrets baked into an exported environment file leak into the repo - use --env-var instead.
  • Newman exits non-zero on any failed assertion, which is what gates the build.
  • Keep collections in sync with the API or tests drift and give false confidence.

Key takeaways

  • Newman runs exported Postman collections in CI.
  • Pass secrets via --env-var, not committed environment files.
  • A failed assertion exits non-zero and fails the build.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →