GitHub Actions
Run Bug0 tests automatically on pull requests and deployments using GitHub Actions.
Prerequisites
Before setting up GitHub Actions:
- Create a Bug0 project with tests
- Generate an API key (see API Keys)
- Add the secret to your GitHub repository
Adding the Secret
- Go to your GitHub repository
- Navigate to Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
BUG0_API_KEY - Value: Your Bug0 API key
- Click Add secret
Also add your project ID:
- Name:
BUG0_PROJECT_ID - Value: Your Bug0 project ID (from the URL)
Basic Workflow
Create .github/workflows/bug0-tests.yml:
name: Bug0 Tests
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Trigger Bug0 Tests
run: |
curl -X POST https://app.bug0.com/api/run-tests \
-H "x-api-key: ${{ secrets.BUG0_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
"projectId": "${{ secrets.BUG0_PROJECT_ID }}",
"gitCommitSha": "${{ github.event.pull_request.head.sha }}",
"gitBranch": "${{ github.head_ref }}",
"prNumber": "${{ github.event.pull_request.number }}"
}'
With Vercel Preview URLs
If you use Vercel, wait for the preview deployment:
name: Bug0 Tests
on:
deployment_status
jobs:
test:
runs-on: ubuntu-latest
if: github.event.deployment_status.state == 'success'
steps:
- name: Trigger Bug0 Tests
run: |
curl -X POST https://app.bug0.com/api/run-tests \
-H "x-api-key: ${{ secrets.BUG0_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
"projectId": "${{ secrets.BUG0_PROJECT_ID }}",
"url": "${{ github.event.deployment_status.target_url }}",
"gitCommitSha": "${{ github.event.deployment.sha }}",
"gitBranch": "${{ github.event.deployment.ref }}",
"prNumber": "${{ github.event.deployment.payload.pr_number }}"
}'
With Netlify Preview URLs
For Netlify deployments:
name: Bug0 Tests
on:
deployment_status
jobs:
test:
runs-on: ubuntu-latest
if: github.event.deployment_status.state == 'success' && contains(github.event.deployment_status.target_url, 'netlify')
steps:
- name: Trigger Bug0 Tests
run: |
curl -X POST https://app.bug0.com/api/run-tests \
-H "x-api-key: ${{ secrets.BUG0_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
"projectId": "${{ secrets.BUG0_PROJECT_ID }}",
"url": "${{ github.event.deployment_status.target_url }}"
}'
Manual Trigger
Add manual workflow dispatch:
name: Bug0 Tests
on:
workflow_dispatch:
inputs:
url:
description: 'URL to test'
required: false
default: ''
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Trigger Bug0 Tests
run: |
URL="${{ github.event.inputs.url }}"
if [ -z "$URL" ]; then
URL_PARAM=""
else
URL_PARAM='"url": "'"$URL"'",'
fi
curl -X POST https://app.bug0.com/api/run-tests \
-H "x-api-key: ${{ secrets.BUG0_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
'"$URL_PARAM"'
"projectId": "${{ secrets.BUG0_PROJECT_ID }}"
}'
Full Example with All Features
name: Bug0 E2E Tests
on:
pull_request:
types: [opened, synchronize, reopened]
deployment_status:
workflow_dispatch:
inputs:
url:
description: 'Custom URL to test'
required: false
jobs:
test-on-preview:
runs-on: ubuntu-latest
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success'
steps:
- name: Run Bug0 Tests on Preview
run: |
curl -X POST https://app.bug0.com/api/run-tests \
-H "x-api-key: ${{ secrets.BUG0_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
"projectId": "${{ secrets.BUG0_PROJECT_ID }}",
"url": "${{ github.event.deployment_status.target_url }}",
"gitCommitSha": "${{ github.event.deployment.sha }}",
"gitBranch": "${{ github.event.deployment.ref }}"
}'
test-manual:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- name: Run Bug0 Tests Manually
run: |
URL="${{ github.event.inputs.url }}"
BODY='{"projectId": "${{ secrets.BUG0_PROJECT_ID }}"'
if [ -n "$URL" ]; then
BODY="$BODY"', "url": "'"$URL"'"'
fi
BODY="$BODY}"
curl -X POST https://app.bug0.com/api/run-tests \
-H "x-api-key: ${{ secrets.BUG0_API_KEY }}" \
-H "Content-Type: application/json" \
-d "$BODY"
GitHub Integration Features
When you include git information in the request:
Commit Status
GitHub shows test status on commits:
- ✅ Passing - "Bug0 QA Agent - All tests passing!"
- ❌ Failing - "Bug0 QA Agent - 2 tests failed"
PR Comments
Bug0 comments on PRs with:
- Pass/fail summary
- Test count and duration
- Link to full report
For PR comments and commit status, connect your GitHub repository in Bug0's project integrations settings.
Troubleshooting
Tests Not Triggering
- Check workflow file syntax (YAML)
- Verify secrets are set correctly
- Check workflow permissions
- Review Actions tab for errors
Wrong URL Being Tested
- Verify
target_urlis correct in logs - Check deployment_status event payload
- Ensure preview URL is accessible
No PR Comments
- Connect GitHub integration in Bug0
- Verify PR number is passed correctly
- Check GitHub App permissions