Bruno API Client | Blog & News

How to Automate API Testing in CI/CD Using GitHub Actions + Bruno

Written by Ganesh Patil | Jul 2, 2025

Continuous Integration and Continuous Delivery (CI/CD) has become essential for modern software development teams. When it comes to API testing automation, GitHub Actions stands out as a powerful platform that seamlessly integrates with your existing GitHub workflow.

Bruno CLI takes this integration to the next level by providing a robust command-line interface that works perfectly within GitHub Actions workflows. No more manual API testing or complex setup processesβ€”just automated, reliable API testing that runs with every code push.

This guide assumes you have a GitHub repository with Bruno collections already set up. If you're new to Bruno, check out our getting started guide first.

 Prerequisites

Before setting up GitHub Actions with Bruno CLI, ensure you have:

  • A GitHub repository containing your Bruno collections
  • Basic understanding of GitHub Actions workflows

πŸ“ Organizing Your Bruno Collections

Proper organization is key to successful CI/CD integration. Here's the recommended structure for your repository:

your-api-project/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── api-tests.yml
β”œβ”€β”€ collections/
β”‚   β”œβ”€β”€ authentication/
β”‚   β”‚   β”œβ”€β”€ login.bru
β”‚   β”‚   └── logout.bru
β”œβ”€β”€ environments/
β”‚   β”œβ”€β”€ development.bru
β”‚   β”œβ”€β”€ ci.bru
β”‚   └── production.bru
└── bruno.json

Key points:

  • .github/workflows/ - Contains your GitHub Actions workflow files
  • collections/ - Your Bruno API collections organized by feature
  • environments/ - Environment-specific configuration files
  • ci.bru - Environment file for CI/CD testing

βš™οΈ Creating Your GitHub Actions Workflow

Create a new file at .github/workflows/api-tests.yml in your repository. This workflow will automatically run your API tests on every push and pull request.

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 workflow does:

  • Triggers: Runs on pushes to main branch and pull requests
  • Environment: Uses Ubuntu latest runner
  • Setup: Checks out code and installs Node.js 20
  • Installation: Installs Bruno CLI globally
  • Testing: Runs API tests with CI environment and generates HTML report
  • Artifacts: Uploads test results for later analysis

πŸ” Security and Environment Variables

For secure API testing, use GitHub's encrypted secrets to store sensitive data:

- name: Run API Tests with Secrets
  run: |
    bru run --env ci \
      --env-var API_KEY=$ \
      --env-var JWT_TOKEN=$
  env:
    API_BASE_URL: $

Setting up secrets:

  1. Go to your GitHub repository
  2. Navigate to Settings β†’ Secrets and variables β†’ Actions
  3. Click New repository secret
  4. Add your sensitive data (API keys, tokens, etc.)

 

πŸ” Monitoring and Troubleshooting

Monitor your API testing workflows effectively:

Workflow Status

  • Check the Actions tab in your GitHub repository
  • Monitor build status and execution time
  • Review logs for any failures or issues

Test Results Analysis

  • Download artifacts from successful builds
  • Analyze HTML reports test-results.html for detailed test results
  • Use JUnit reports for integration with other tools

 

πŸ”— Try the Demo Yourself

We’ve published the full working collection on GitHub. You can either clone this, or simply click the Fetch in Bruno button below!

 

 

πŸ’­ Final Thoughts

GitHub Actions integration with Bruno CLI provides a powerful, automated solution for API testing. By following the patterns and best practices outlined in this guide, you can create reliable, maintainable CI/CD pipelines that ensure your APIs remain stable and functional.

Ready to automate your API testing? Start with the basic workflow and gradually add advanced features as your needs grow.

Happy testing! πŸš€