CI & Automation

Run the Stepshots CLI in CI — machine-readable --json output, exit codes, verify and tour check drift gates, dry-run validation, and the hauju/stepshots GitHub Action for recording and publishing demos in pipelines.

Overview

Every Stepshots command runs headless and non-interactive, so the CLI fits cleanly into CI pipelines and agent workflows. This guide covers the pieces that matter for automation: machine-readable output, exit codes, drift checks, and the ready-made GitHub Action.

Machine-readable output

Pass --json to any command to get structured output on stdout instead of human-formatted text. It's the same flag everywhere — for AI agents and automation:

bash
stepshots verify --json > report.json
stepshots list --json
stepshots doctor --json

Errors are emitted as JSON too, with an error category, so a pipeline can branch on what went wrong.

Exit codes

The CLI exits 0 on success and maps each failure category to a stable code, so a pipeline can react without parsing text:

Code Category Meaning
0 — Success.
1 config Config, I/O, upgrade, or other general error.
2 browser Chrome failed to launch or a CDP call failed.
3 action A step couldn't execute (e.g. a selector no longer matches).
4 bundle Failed to build or read the .stepshot bundle.
5 upload / auth Upload failed or authentication was rejected.

Validate before recording

record --dry-run parses and validates the config and reports what would be recorded without launching a browser — a fast config check for pull requests:

bash
stepshots record --dry-run

Detect drift with verify

stepshots verify replays your tutorials against the live app and reports which steps or annotations no longer match, without writing a bundle. It's the check to run on a schedule so a redesign never silently breaks your demos:

bash
stepshots verify --fail-on warn --save-failures ./drift
  • --fail-on fail (default) exits non-zero only when a step can no longer execute.
  • --fail-on warn also fails on annotation drift (an annotation that lost its anchor).
  • --save-failures <dir> writes a screenshot of the page at each failure (defaults to output/).

Combine it with --json for a report carrying a repair hint per failure.

Report results to the dashboard

Give a tutorial the id of the demo it was uploaded as, and verify posts each result to that demo while you're logged in (or STEPSHOTS_TOKEN is set). The demo list then shows Verified 3 days ago, 2 steps broken, or Never verified on every card, and the demo page lists the broken steps:

json
"tutorials": {
  "onboarding": {
    "url": "/",
    "title": "Onboarding",
    "demoId": "6650f1c2a8b4e1d2c3f4a5b6",
    "steps": []
  }
}

A config downloaded from a demo's page already carries its demoId. Reporting is best-effort: offline or without a token, verify still runs and only prints a warning.

record also stamps each bundle with the git commit and branch it was recorded from, so the demo page shows which commit the screenshots reflect.

Keep guided tours honest with tour check

verify guards your demos; stepshots tour check guards your guided tours. It replays each tours/*.tour.json headless against a deploy, resolving every step the way the player does — ok (selector matched), drift (only a fallback anchor matched), fail (neither):

bash
stepshots tour validate
stepshots tour check --url https://staging.example.com --fail-on warn

Run both in the same pipeline and selector drift is caught before your users meet it. --update-fallbacks refreshes each step's text/aria anchors from the live DOM, so a green run also keeps the tour's drift resilience fresh.

Check the environment

stepshots doctor verifies the browser, config, server reachability, and login in one pass. Run it early in a job to fail fast with a clear message when something is misconfigured:

bash
stepshots doctor --json

Authenticate and publish

In CI you can't complete a browser login, so authenticate with an API key via STEPSHOTS_TOKEN (generate one from API Keys):

bash
export STEPSHOTS_TOKEN=****
stepshots upload output/onboarding.stepshot --public

Add --public to publish uploaded demos immediately, or --demo-id <id> to replace an existing demo in place.

Chrome sandbox in CI

When the CI environment variable is set, the CLI launches Chrome with --no-sandbox, --disable-gpu, and --disable-dev-shm-usage, which is required in most containerized runners. GitHub Actions sets CI=true automatically. If you run stepshots in another CI system or a container that doesn't set it, export it yourself:

bash
export CI=true

GitHub Action

The repo ships a composite GitHub Action, hauju/stepshots, that installs the CLI, sets up Chrome, and runs record, verify, or tour check for you.

Record and publish on every push to main:

yaml
- uses: hauju/stepshots@main
  with:
    command: record
    config: demo/stepshots.config.json
    upload: "true"
    token: ${{ secrets.STEPSHOTS_TOKEN }}

Check demo freshness on a schedule:

yaml
- uses: hauju/stepshots@main
  with:
    command: verify
    config: demo/stepshots.config.json
    fail-on: warn

The verify run fails the job when drift is found, writes a freshness summary to the job summary, and leaves output/verify-report.json for tooling. Pass token and it also reports each result to the dashboard (see Report results to the dashboard).

Open a pull request when demos drift

With on-drift: pull-request, a failing verify doesn't just fail the job. The action re-records every affected tutorial into bundles-dir, renders a contact sheet per bundle with stepshots sheet, and opens a pull request on the stepshots/re-record branch with the new .stepshot files. The PR body lists each tutorial's findings with its contact sheet embedded. A later run updates the same PR instead of opening another.

yaml
on:
  schedule:
    - cron: "0 6 * * 1"

permissions:
  contents: write        # push the stepshots/re-record branch
  pull-requests: write   # open or update the PR

jobs:
  demos:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: hauju/stepshots@main
        with:
          command: verify
          fail-on: warn
          on-drift: pull-request
          bundles-dir: demos
          token: ${{ secrets.STEPSHOTS_TOKEN }}
  • bundles-dir must be the directory where your .stepshot bundles are committed. Only the re-recorded bundles and their .sheet.png contact sheets are committed.
  • In the repository's Settings → Actions → General, enable Allow GitHub Actions to create and approve pull requests.
  • A step that no longer runs can't be re-recorded from the same config. Such tutorials are listed in the PR body as needing a config fix. If none of the affected tutorials could be re-recorded, the job fails.
  • With the default fail-on: fail, only broken steps trigger the PR. Use fail-on: warn to also re-record demos whose annotations drifted.
  • PRs opened with the default GITHUB_TOKEN don't trigger other workflows. Pass a PAT or GitHub App token as pr-token if your checks must run on them.

Check guided tours against a deploy:

yaml
- uses: hauju/stepshots@main
  with:
    command: tour-check
    url: https://staging.example.com
    fail-on: warn

The tour-check run replays every tours/*.tour.json against url, fails the job when a tour breaks (with fail-on: warn, also on selector drift), writes a tour freshness summary to the job summary, and leaves output/tour-check-report.json for tooling. Add update-fallbacks: "true" to refresh each step's text/aria anchors from the live DOM — the rewritten tour files stay in the workspace, so a later step can commit them.

Inputs

Input Default Description
command record record (capture bundles), verify (drift check, writes no bundles), or tour-check (replay tour files against a live deploy).
config stepshots.config.json Path to the config file.
tutorials all Comma-separated tutorial keys to record or verify.
output output Output directory for bundles (record) or failure screenshots and the report (verify, tour-check).
fail-on fail verify/tour-check: fail on fail (broken steps) or warn (also annotation or fallback-anchor drift).
on-drift fail verify only: fail fails the job; pull-request re-records the affected tutorials and opens a PR (needs contents: write and pull-requests: write).
bundles-dir output verify with on-drift: pull-request: the committed directory holding your bundles; re-recorded bundles and contact sheets go here.
pr-token github.token verify with on-drift: pull-request: token that pushes the branch and opens the PR.
url — tour-check only: base URL of the deploy to replay tours against (required).
tours tours/ tour-check only: comma-separated tour files or directories to check.
update-fallbacks false tour-check only: refresh fallback anchors from the live DOM and rewrite the tour files.
upload false Upload bundles after recording.
token — Stepshots API token (required when upload is true). With verify, also reports results to the dashboard.
server https://stepshots.com Server URL.
demo-id — Replace an existing demo instead of creating a new one.
title — Override the demo title on upload.
version main Stepshots CLI version (git ref) to install.

Outputs

Output Description
bundles Newline-separated list of recorded .stepshot files (record command only).
report Path to the JSON report (verify and tour-check commands only).
pull-request-url URL of the drift PR (verify with on-drift: pull-request).
Navigation