DEV Community

Cover image for How to Automate API Testing in CI/CD Using GitHub Actions + Bruno CLI πŸš€
Ganesh Patil
Ganesh Patil

Posted on • Originally published at blog.usebruno.com

How to Automate API Testing in CI/CD Using GitHub Actions + Bruno CLI πŸš€

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 }}
Enter fullscreen mode Exit fullscreen mode

To set secrets:

  1. Go to your repo
  2. Settings β†’ Secrets and variables β†’ Actions
  3. Click New repository secret
  4. Add your sensitive keys/tokens

GitHub Secrets UI


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

GitHub Actions Tab

View Test Reports

  • Download results.html from the test-results artifact
  • Open in a browser to view full report
  • You can also emit JUnit format if needed for integration

HTML Report


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)