When you push code → pipeline will:
- Install Node.js
- Install Newman
- Run your exported Postman collection
- Fail if API tests fail
Step 1 — Prepare your repo
Create a GitHub repo (or use existing)
Structure:
project/
├── .github/
│ └── workflows/
│ └── api-test.yml
├── devops-lab.json
👉 Put your exported file here:
devops-lab.json
Step 2 — Create GitHub Actions file
Create file:
.github/workflows/api-test.yml
Step 3 — Add this code (READY, CLEAN)
name: API Tests with Newman
on:
push:
branches: [ "main" ]
jobs:
run-api-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install Newman
run: npm install -g newman
- name: Run Postman Collection
run: newman run devops-lab.json
Step 4 — Push to GitHub
git add .
git commit -m "add api test pipeline"
git push origin main
Step 5 — Go to GitHub
👉 Open your repo
👉 Click Actions tab
You will see:
API Tests with Newman → Running
Expected result
If everything works:
✔ Status is 200
✔ Response is not empty
Job status:
✅ SUCCESS
What happens if API breaks?
Example:
- API returns 500
- Test fails
Then:
❌ FAILED
👉 Pipeline stops
👉 Deployment blocked
Real DevOps Flow (IMPORTANT)
Developer pushes code
↓
GitHub Actions runs
↓
Deploy app (optional step)
↓
Run Newman tests
↓
If FAIL → stop
If PASS → continue
Step 6 — (OPTIONAL but PRO LEVEL)
Add environment file:
dev.json
Then run:
- name: Run Postman Collection
run: newman run devops-lab.json -e dev.json
Interview answer (use this)
“I integrate Postman collections into GitHub Actions using Newman. The pipeline runs API tests automatically after code changes and fails the build if any validation fails.”
Top comments (0)