Documentation Menu

Preview vs Production Workflow

The gold standard for modern visual regression: Catching bugs before they merge by directly comparing temporary Preview environments to the Live Production site.

The Strategy

Traditional visual testing requires you to manage a "golden image" baseline in your git repository. This is painful—it bloats your repo, creates merge conflicts, and the baselines are often out of date.

RegressionBot recommendation: Use your live Production site as the baseline. When a developer opens a PR, compare their Preview URL against the Live URL. No images in git, zero maintenance.

Zero Baseline Bloat

Stop storing thousands of PNGs in your Git history. Let the cloud handle it.

Self-Healing

Baselines naturally update automatically as your production site evolves.

The 3-Step Lifecycle

1

Automated Check CI/CD

On every push, GitHub Actions waits for your preview deployment to finish and then triggers a RegressionBot job. It renders screenshots of both the preview URL and production URL to compare them.

2

Visual Review Developer

If regressions are detected, the PR check fails. The developer follows the link in the PR comment to inspect the diff images.

3

Approval ChatOps

If the change is intentional (e.g., a new UI feature), the developer comments /approve-visual on the PR. RegressionBot approves the job, and the PR check turns green. In a live-vs-live run (a preview compared against production) there is no stored baseline to move, so approving records the decision and turns the check green but changes no baseline.

This approves every page in the job. To approve only the pages the verdict cleared and leave the flagged ones pending, add --decision intentional,noise to the CLI (SDK 2.3.0 or later), or call POST /approve with a where filter, or use the approve_job MCP tool. See Intent and the Verdict.

GitHub Actions Configuration

The simplest way to integrate RegressionBot is by using our official shared GitHub Action, which automatically triggers runs and generates formatted markdown reports.

The action passes or fails the workflow job according to its fail-on input (change, review, bug or none) and posts or updates a comment on the pull request. To block merging on it, make the workflow job a required status check in your branch protection rules.

name: Visual Check
on:
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write # Required to post/update comments on your PR
    steps:
      - uses: actions/checkout@v4

      # Replace this with your preview provider's output or dynamic setup.
      - name: Set preview URL
        run: echo "PREVIEW_URL=https://preview.myapp.com" >> "$GITHUB_ENV"

      - name: Run Visual Check
        id: vrs
        uses: RegressionBot/regressionbot-action@v0
        with:
          api-key: ${{ secrets.REGRESSIONBOT_API_KEY }}
          test-origin: ${{ env.PREVIEW_URL }}
          base-origin: 'https://myapp.com'
          sitemap-url: '${{ env.PREVIEW_URL }}/sitemap.xml'
          scan: '**'
          project: 'my-web-app'
          devices: 'Desktop Chrome, iPhone 12'
          github-token: ${{ secrets.GITHUB_TOKEN }}

The Action reads the pull request's title, description (the first 2,000 characters) and head commit SHA from the event itself, so the run is judged against what the PR says it does, with no run-context input to add. On a push it uses the commit message and SHA. A workflow that sets nothing still sends this context; set change-description to say it yourself (explicit inputs win), or send-pr-context: 'false' to send nothing. Without any intent a run is not_judged: add a standing intent to the project, or let the PR supply one.

⚠️ Forked Repositories & PR PermissionsBy default, GitHub Actions runs triggered by pull requests from forked repositories have a read-only GITHUB_TOKEN for security. This will cause comment creation/update steps to fail. If you accept community contributions from forks, you should run the workflow on the pull_request_target event (with appropriate checkouts) or configure the comment steps to fail gracefully using continue-on-error: true.

For advanced custom integrations where you want to write your own reporting logic or parse raw job outputs, you can also use our Node.js SDK:

name: Visual Check
on:
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write # Required to post/update comments on your PR
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20

      # Replace this with your preview provider's output.
      - name: Set preview URL
        run: echo "PREVIEW_URL=https://preview.myapp.com" >> "$GITHUB_ENV"

      - name: Install RegressionBot SDK
        run: npm install @regressionbot/sdk

      - name: Run RegressionBot and write report
        run: |
          node --input-type=module <<'EOF'
          import fs from 'node:fs';
          import { RegressionBot } from '@regressionbot/sdk';

          const client = new RegressionBot(process.env.REGRESSIONBOT_API_KEY);
          const job = await client
            .test(process.env.PREVIEW_URL)
            .against('https://myapp.com')
            .forProject('my-web-app')
            .on(['Desktop Chrome', 'iPhone 12'])
            .sitemap(process.env.PREVIEW_URL + '/sitemap.xml')
            .scan('/pages/**')
            .withContext({
              prTitle: process.env.PR_TITLE,
              prDescription: process.env.PR_BODY,
              gitCommitSha: process.env.PR_HEAD_SHA
            })
            .run();

          await job.waitForCompletion(5000, undefined, { waitForSummaries: true });
          const summary = await job.getSummary();

          const lines = [
            '## 🚀 RegressionBot Visual Test Results',
            '',
            '**Job ID:** `' + job.jobId + '`',
            '**Pages changed:** ' + summary.regressionCount,
            ''
          ];

          for (const regression of summary.regressions || []) {
            const diff = (regression.diffPercentage ?? 0).toFixed(3);
            lines.push(
              '### ' + regression.url,
              '',
              '**Variant:** ' + regression.variantName,
              '**Changes:** ' + (regression.changes?.length ?? 0) + ' (' + diff + '% of the page)',
              ''
            );

            if (regression.regressionbotSummary) {
              const summaryLines = Array.isArray(regression.regressionbotSummary)
                ? regression.regressionbotSummary.map((item) =>
                    item.label ? '**' + item.label + '**: ' + item.text : item.text)
                : [regression.regressionbotSummary];
              lines.push(
                '> **RegressionBot Summary:**',
                ...summaryLines.map((l) => '> ' + l),
                ''
              );
            }

            if (regression.diffUrl) {
              lines.push('[Open diff image](' + regression.diffUrl + ')', '');
            }
          }

          fs.writeFileSync('regressionbot-report.md', lines.join('
'));
          if (summary.regressionCount > 0) process.exit(1);
          EOF
        env:
          REGRESSIONBOT_API_KEY: ${{ secrets.REGRESSIONBOT_API_KEY }}
          PR_TITLE: ${{ github.event.pull_request.title }}
          PR_BODY: ${{ github.event.pull_request.body }}
          PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

      - name: Comment visual summary on PR
        if: always()
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const body = fs.existsSync('regressionbot-report.md')
              ? fs.readFileSync('regressionbot-report.md', 'utf8')
              : 'RegressionBot did not produce a report. Check the workflow logs.';

            const { data: comments } = await github.rest.issues.listComments({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
            });

            const botComment = comments.find(comment => 
              comment.body.includes('🚀 RegressionBot Visual Test Results')
            );

            if (botComment) {
              await github.rest.issues.updateComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                comment_id: botComment.id,
                body
              });
            } else {
              await github.rest.issues.createComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: context.issue.number,
                body
              });
            }
          

Skipping Docs-Only Pull Requests

A workflow triggered by on: pull_request or push can use a paths: or paths-ignore: filter to stay quiet when only documentation changed. A workflow that starts from a preview provider's status (or check_run) event cannot: GitHub does not apply paths: filters to those events, so every successful preview status starts a full visual run, typo-only and docs-only pull requests included.

Do the filtering inside the job instead. List the files changed on the status's commit, and skip the visual step when every one is documentation. The job itself still runs and finishes green, which matters if it is a required check: a job that is skipped with a job-level if: reports as skipped, and a required check that never reports can block the merge, so skip the step, not the job.

on:
  status:

jobs:
  visual-check:
    if: github.event.state == 'success'
    runs-on: ubuntu-latest
    steps:
      - name: Skip when only documentation changed
        id: paths
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SHA: ${{ github.event.sha }}
          REPO: ${{ github.repository }}
        run: |
          files=$(gh api "repos/$REPO/commits/$SHA" --jq '.files[].filename')
          # Anything that is not documentation means the visual run is needed.
          # An empty or failed listing runs the check rather than skipping it.
          if [ -n "$files" ] && ! echo "$files" | grep -qvE '\.(md|mdx)$|^docs/|^content/docs/'; then
            echo "docs_only=true" >> "$GITHUB_OUTPUT"
            echo "Only documentation changed; skipping the visual run."
          fi

      - name: Visual regression run
        if: steps.paths.outputs.docs_only != 'true'
        uses: RegressionBot/regressionbot-action@v0
        with:
          api-key: ${{ secrets.REGRESSIONBOT_API_KEY }}
          # ...the same inputs as the workflow above

Adjust the pattern to where your documentation lives (*.md, *.mdx, docs/, or a content folder such as content/docs/). The commit listing returns up to 300 files; a larger change is rarely docs-only, and the step above runs the check whenever it cannot prove otherwise. A check_run-triggered workflow works the same way, using the check run's head_sha in place of the status's sha.

A Quick Check on Every Push

For pull requests that change copy, navigation or content rather than styling, a quick check compares the preview against production in a few seconds a page, with no screenshots. It catches a removed link, a rewritten heading or a dropped section; it does not see layout, color or image changes, so keep the full check for pull requests that touch CSS. The GitHub Action does not take fidelity yet, so call the API directly:

      - name: Quick check against production
        env:
          REGRESSIONBOT_API_KEY: ${{ secrets.REGRESSIONBOT_API_KEY }}
          PREVIEW_URL: ${{ env.PREVIEW_URL }}   # from your preview provider, as above
        run: |
          API=https://api.regressionbot.com
          AUTH="Authorization: Bearer $REGRESSIONBOT_API_KEY"

          # Production's sitemap, so a page the preview dropped is still checked (and fails).
          # A password-protected preview: add "project": "<name>" for a project holding its credential.
          RESP=$(curl -s -X POST $API/crawl -H "$AUTH" -H "Content-Type: application/json" -d '{
            "testOrigin": "'"$PREVIEW_URL"'",
            "baseOrigin": "https://myapp.com",
            "sitemapUrl": "https://myapp.com/sitemap.xml",
            "scans": [{ "pattern": "**" }],
            "fidelity": "low"
          }')
          # A bad key, a bad body or a refused run returns no jobId: print why and stop.
          JOB_ID=$(echo "$RESP" | jq -r '.jobId // empty' 2>/dev/null || true)
          [ -n "$JOB_ID" ] || { echo "Run not started: $RESP"; exit 1; }

          # Finished states: COMPLETED, FAILED, APPROVED, RESOLVED (every page decided, one or more rejected).
          # A quick check of 100 pages takes a few minutes, and a run is allowed up to 40; give up after 45.
          DONE=
          for i in $(seq 270); do
            curl -s $API/job/$JOB_ID -H "$AUTH" | jq -e '.status | IN("COMPLETED","FAILED","APPROVED","RESOLVED")' >/dev/null && { DONE=1; break; }
            sleep 10
          done
          [ -n "$DONE" ] || { echo "Job $JOB_ID did not finish within 45 minutes"; exit 1; }

          SUMMARY=$(curl -s $API/job/$JOB_ID/summary -H "$AUTH")
          echo "$SUMMARY" | jq -r '"status: \(.status)", (.scopeNote // empty), (.error // empty | "error: \(.)"),
            (.errors[]? | "ERROR \(.url) [\(.variantName)]: \(.errorMessage)"),
            (.regressions[] | .url, ((.changes // [])[] | "  \(.type) \(.element): \(.before // "") -> \(.after // "") \(.attributes // "")"))'
          # Pass only when the job completed (or was approved), checked at least one page, and found no change or error.
          # RESOLVED fails: someone rejected a page.
          echo "$SUMMARY" | jq -e '(.status | IN("COMPLETED","APPROVED")) and .totalUrls > 0 and .regressionCount == 0 and .errorCount == 0' >/dev/null

The step fails when the run could not start, when the job is still running after 45 minutes, and when the job failed, was rejected, checked nothing, or found a change or an unreadable page. GitHub's Ubuntu runners include jq. A page that errors says why (Page errors): “Page missing” for a page the preview dropped, “Page refused” for a password gate or a firewall. For a gate, store the credential on a project and pass its name as project (Gated Preview URLs). A preview behind a login form reads as the form, so every page shows as changed.

Enable ChatOps Approval

To allow developers to approve changes directly from comments, add this "Approval" workflow. This will also update the commit status check on GitHub to green.

npx regressionbot approve $JOB_ID approves every page in the job, including any page whose verdict is bug or needs_review. From SDK 2.3.0 the CLI takes --decision intentional,noise, which approves only what the verdict cleared and prints how many pages it left for a person. The equivalent over REST is POST /approve carrying a where filter:

curl -s -X POST https://api.regressionbot.com/approve \
  -H "Authorization: Bearer $REGRESSIONBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jobId": "'"$JOB_ID"'", "where": {"decision": ["intentional", "noise"]}}'

# → { "approvedUrlsCount": 3, "skippedUrlsCount": 2, "conflictedUrls": [] }

skippedUrlsCount is the changed pages left pending because their verdict was outside the list, or because they had no verdict at all. conflictedUrls lists pages skipped because another job moved their baseline first. If the count is above zero, leave the commit status check red — a person still has pages to decide. The approve_job MCP tool takes the same where filter and is described in Intent and the Verdict.

on:
  issue_comment:
    types: [created]

jobs:
  approve:
    if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/approve-visual')
    runs-on: ubuntu-latest
    permissions:
      statuses: write # Required to update commit status check
      pull-requests: read
    steps:
      - name: Approve RegressionBot Job
        run: |
          JOB_ID=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments --jq '.[] | select(.body | contains("🚀 RegressionBot Visual Test Results")) | .body' | grep "Job ID:" | awk -F'`' '{print $2}' | tail -n 1)
          if [ -z "$JOB_ID" ]; then
            echo "Error: Could not find a RegressionBot job ID for this PR."
            exit 1
          fi
          npx regressionbot approve "$JOB_ID"
        env:
          REGRESSIONBOT_API_KEY: ${{ secrets.REGRESSIONBOT_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Update GitHub status check to success
        run: |
          # Fetch PR head SHA
          SHA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} --jq '.head.sha')
          
          # Mark visual regression status check as green/success
          gh api \
            --method POST \
            -H "Accept: application/vnd.github+json" \
            /repos/${{ github.repository }}/statuses/$SHA \
            -f state='success'             -f target_url="${{ github.event.comment.html_url }}"             -f description='Visual regressions approved by developer'             -f context='RegressionBot Visual Check'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}