Set up CI with one command
`@@CLI@@ ci init github` writes a GitHub Actions workflow that runs HeyBug on every pull request.
heybug ci init github writes a GitHub Actions workflow that runs HeyBug on every pull request. You run one command, add one secret and open a pull request. The workflow is safe by default: it skips forks, drafts and Dependabot, and it runs once per pull request. If the workflow file already exists, the command stops and leaves it alone.
For how the run and the check work, read Run tests in CI.
Before you start
- A GitHub repository and a HeyBug project. Note the project ID.
- An API token. Open API tokens in the sidebar (
/settings/tokens), create one and copy it. It is shown once. - The
heybugCLI on your machine (CLI).
Steps
1. Write the workflow
Run this in the root of your repository:
heybug ci init github --project <project-id>The command writes .github/workflows/heybug.yml and prints:
Wrote .github/workflows/heybug.yml
Add your API token as the HEYBUG_TOKEN repository secret (or re-run with --set-secret).To see the file without writing it, add --dry-run. Other flags: --path picks a different file, and --force overwrites an existing one.
2. Add the token as a secret
Pick one:
- In GitHub. Open repository settings, then Secrets and variables, then Actions. Add a repository secret named
HEYBUG_TOKENwith your token. - With the GitHub CLI. Install
gh, export your token asHEYBUG_TOKEN, and runheybug ci init github --project <project-id> --set-secretinstead of step 1. It writes the same file and stores the secret. The token goes toghon stdin and is never printed.
3. Add the server as a variable
On the same Actions page, open Variables and add a repository variable named HEYBUG_SERVER. Use your server address, for example https://opentest.nagara.cloud.
If you left out --project, also add a variable named HEYBUG_PROJECT with the project ID. The workflow reads it.
4. Open a pull request
Commit .github/workflows/heybug.yml, push a branch and open a pull request. The HeyBug job starts on the pull request.
The generated file
This is the whole file. The project ID is filled in from --project.
name: HeyBug
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
# One run per pull request; a new push cancels the older run.
concurrency:
group: heybug-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
checks: read
deployments: read
jobs:
heybug:
name: HeyBug
# Skip drafts, forks (no access to secrets) and Dependabot.
if: >-
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
timeout-minutes: 30
env:
HEYBUG_TOKEN: ${{ secrets.HEYBUG_TOKEN }}
HEYBUG_SERVER: ${{ vars.HEYBUG_SERVER }}
GITHUB_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install the HeyBug CLI
run: |
curl -fsSL https://github.com/catalysync/heybug/releases/latest/download/heybug_linux_amd64.tar.gz | tar -xz -C "$RUNNER_TEMP" heybug
echo "$RUNNER_TEMP" >> "$GITHUB_PATH"
- name: Run HeyBug
run: heybug ci run --project "<project-id>" --report junit --report-file heybug-junit.xml
- name: Upload the report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: heybug-junit
path: heybug-junit.xml
if-no-files-found: ignoreThe first pull request result
The check appears on the pull request while the run executes. Open the job log and find the Run HeyBug step. It prints the run link first, then the verdict:
Run <run-id>: <link to the run>
<status>: <passed> passed, <failed> failed, <errored> errored of <total>Open the link to see each test, its steps and its screenshots. The job also uploads the JUnit report as an artifact named heybug-junit, so you can read it without the web app.
A passing run turns the check green. A failed or errored test turns it red. Merge is blocked only if you require the check in branch protection (Run tests in CI).
When it fails
| What you see | Why | What to do |
|---|---|---|
already exists. Use --force to overwrite it. | The workflow file is already in the repository. | Keep it, or run the command again with --force and review the diff. |
--project is required | No --project was given and the HEYBUG_PROJECT variable is empty. | Add the HEYBUG_PROJECT variable, or set the project in the workflow. |
| Job fails with an authentication error (exit code 3) | The HEYBUG_TOKEN secret is missing, wrong or revoked. | Create a new token and save it as the HEYBUG_TOKEN secret. |
Skipped: no tests were selected. | The project has no tests selected. | Apply a plan that has tests, then push again. If an empty run should pass, add --allow-skip to the Run HeyBug step. |
| No HeyBug job on a pull request | The pull request is a draft, comes from a fork, or comes from Dependabot. | Mark it ready for review. Forks never get secrets, so HeyBug does not run on them. |
| The run link says the tests failed | A test failed in your app. | Open the run, read the failing step and the expected and actual results, fix the app, then push. |
If your app needs a preview URL for each pull request, the workflow needs a deploy step first. See Run tests in CI for the two patterns, and CI security for what the token can do.