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.
Before setting up GitHub Actions with Bruno CLI, ensure you have:
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 filescollections/
- Your Bruno API collections organized by featureenvironments/
- Environment-specific configuration filesci.bru
- Environment file for CI/CD testingCreate 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:
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:
Monitor your API testing workflows effectively:
Weβve published the full working collection on GitHub. You can either clone this, or simply click the Fetch in Bruno button below!
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! π