CI/CD is table stakes for modern dev teams β and if you're building APIs, test automation should be too. GitHub Actions is a fantastic platform for integrating tests directly into your dev flow.
Bruno CLI makes it dead simple to run your API tests as part of every commit and pull request. No more manual testing or flaky setup β just repeatable, scriptable tests that run on autopilot.
β οΈ This guide assumes youβve already got a GitHub repo with Bruno collections. If not, start here.
β Prerequisites
Before you set up the GitHub Action, make sure youβve got:
- A GitHub repo with Bruno collections committed
- Some familiarity with GitHub Actions YAML syntax
Organizing Your Bruno Collections
Structure your repo like this:
your-api-project/
βββ .github/
β βββ workflows/
β βββ api-tests.yml
βββ collections/
β βββ authentication/
β β βββ login.bru
β β βββ logout.bru
βββ environments/
β βββ development.bru
β βββ ci.bru
β βββ production.bru
βββ bruno.json
Why it matters:
-
.github/workflows/
β stores GitHub Actions -
collections/
β organized Bruno test collections -
environments/ci.bru
β test-specific environment config
βοΈ GitHub Actions Workflow
Create a file at .github/workflows/api-tests.yml
:
name: API Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Bruno CLI
run: npm install -g @usebruno/cli
- name: Run API Tests
run: bru run --env ci --reporter-html results.html
- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: test-results
path: results.html
What this does:
- Runs on push/PR to
main
- Sets up Node 20, installs Bruno CLI
- Executes API tests with
ci
environment - Uploads the HTML test report as an artifact
Securing Sensitive Data with GitHub Secrets
If you use secrets like API keys or tokens, pass them safely like this:
- name: Run API Tests with Secrets
run: |
bru run --env ci \
--env-var API_KEY=${{ secrets.API_KEY }} \
--env-var JWT_TOKEN=${{ secrets.JWT_TOKEN }}
env:
API_BASE_URL: ${{ secrets.API_BASE_URL }}
To set secrets:
- Go to your repo
-
Settings β Secrets and variables β Actions
- Click
New repository secret
- Add your sensitive keys/tokens
Monitoring & Debugging
β Check Build Status
- Go to the Actions tab in your repo
- Youβll see the workflow listed by commit
- Expand any job to view logs and timing
View Test Reports
- Download
results.html
from thetest-results
artifact - Open in a browser to view full report
- You can also emit JUnit format if needed for integration
Try the Demo Collection
Weβve open-sourced a working example at bruno-collections/github-actions.
Final Thoughts
GitHub Actions + Bruno CLI is a killer combo for shipping fast, tested, and reliable APIs. Start with a simple workflow, evolve it as you grow.
Automate it. Test it. Ship it.
Happy testing π
Top comments (0)