Skip to Content
HeyBug docs
Guides

Run HeyBug with the GitHub Action

The HeyBug action runs your project's tests from a GitHub workflow.

The HeyBug action runs your project's tests from a GitHub workflow. It downloads the HeyBug CLI, runs heybug ci run for one project, and waits for the verdict. When blocking is on, a failed run fails the job, so the pull request cannot merge if your branch protection requires the job.

Use the action when you want one uses: step instead of writing the install and run commands yourself. The action lives in this repository at action/heybug. For the full CI set-up, the check name and the two ways to get a preview URL, read Run tests in CI.

Inputs

InputRequiredDefaultWhat it does
tokenyesnoneAPI token with the run:tests and read:tests scopes. Store it as the HEYBUG_TOKEN secret. See CI security.
projectyesnoneProject id to test. Passed to heybug ci run --project.
target-urlnoproject defaultURL of the app to test. Leave it empty to use the project's default URL.
blockingnotruetrue fails the job when the run fails. false reports the failure as a warning and the job passes.

What the action does

  1. Installs the CLI. It downloads the latest HeyBug CLI release for Linux x64 and adds it to PATH. The runner must be Linux x64, such as ubuntu-latest.
  2. Runs the tests. It runs heybug ci run --project <project>, adding --target-url when you set one. The command waits until the run finishes.
  3. Gates the job. The command exits 0 when every test passed. Any other exit code fails the job when blocking is true. When blocking is false, the action logs a warning and exits 0.

The CLI version is not pinned by the action. Each run uses the latest release. Pinning the action by SHA fixes the action's own steps, not the CLI.

Example workflow

This workflow tests every pull request against the staging URL in a repository variable. It uses the project id from the HEYBUG_PROJECT repository variable.

name: HeyBug
on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]
permissions:
  contents: read
jobs:
  tests:
    # Forks get no secrets, and drafts are not tested yet.
    if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.repository
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - name: Run HeyBug
        uses: heybug/action@<full-commit-sha>
        with:
          token: ${{ secrets.HEYBUG_TOKEN }}
          project: ${{ vars.HEYBUG_PROJECT }}
          target-url: ${{ vars.STAGING_URL }}
          blocking: true

Replace <full-commit-sha> with the full 40-character commit SHA of the action version you reviewed. A tag can move; a SHA cannot. Do not use a branch name.

The if line skips forks and drafts. A fork's pull request gets no secrets, so the token would be empty and the run would fail with exit code 3.

Pin the action by SHA

Pin the action to a SHA in production workflows. Update the SHA on purpose, after you read what changed in the action. Store the token only in the secret. Do not print it in a run: step.

When the job fails

Read the run link in the job log first. The CLI prints Run <id>: <url> before it waits, and the final line gives the counts, for example failed: 1 passed, 2 failed, 0 errored of 3.

Log or exit codeWhat it meansWhat to do
Exit 1, failedA test failed or errored.Open the run link and read the failing test. See Getting started, step 5.
Exit 3, token missing or invalidThe token input is empty, the secret is missing, or the token was revoked.Check the HEYBUG_TOKEN secret. If the token was revoked, create a new one under API tokens (/settings/tokens).
Exit 5, Skipped: no tests were selectedThe project has no tests to run. The action has no allow-skip input, so a skipped run fails the job when blocking is true.Add tests to the project. Or set blocking: false for this step.
Exit 2, usage errorAn input is wrong.Check that project is set and that the input names match the table above.
The install step failsThe release could not be downloaded, or the runner is not Linux x64.Use runs-on: ubuntu-latest. Retry the job. If it keeps failing, check the release page for your repository.

When blocking is false, every failure above still appears in the log. Only the job's status changes, so use it while you are adding tests, not as a permanent setting.

For the exit codes of the CLI itself, see CLI.

On this page