sireg
Browse documentation

Next.js static export

Build a static export and check the generated Next.js site inside Actions.

Save the workflow as .github/workflows/website-regression.yml and set PRODUCTION_SITEMAP to your live sitemap. Commit package-lock.json and provide an npm build script that runs next build. In next.config.mjs, enable the static export and directory-style URLs:

JavaScript
export default {
  output: 'export',
  trailingSlash: true,
};

The workflow serves out/. With trailingSlash: true, Next.js writes files such as out/about/index.html, and the sitemap should list the canonical /about/ URL. If your Next.js config sets a basePath such as /docs, set SITE_PREFIX to that same path without a trailing slash. Keep / at the domain root.

For apps that need a server at request time, use a Vercel Preview Deployment.

Download nextjs.yml

YAML
name: Next.js static export regression

on: [pull_request]

permissions:
  contents: read

env:
  PRODUCTION_SITEMAP: https://example.com/sitemap.xml
  SITE_PREFIX: /

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - name: Build the website
        run: |
          npm ci
          npm run build
      - name: Serve the build and check routes
        env:
          BUILD_DIR: out
          PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
        run: |
          SITE_ORIGIN=http://127.0.0.1:8000
          serve_dir="$BUILD_DIR"
          if [[ "$SITE_PREFIX" != "/" ]]; then
            serve_dir="$(mktemp -d "$RUNNER_TEMP/sireg-site.XXXXXX")"
            mkdir -p "$(dirname "$serve_dir$SITE_PREFIX")"
            ln -s "$PWD/$BUILD_DIR" "$serve_dir$SITE_PREFIX"
          fi

          python3 -m http.server 8000 --bind 127.0.0.1 --directory "$serve_dir" > "$RUNNER_TEMP/site.log" 2>&1 &
          server=$!
          trap 'kill "$server" 2>/dev/null || true' EXIT
          curl --fail --silent --show-error --retry 10 --retry-delay 1 --retry-connrefused \
            "$SITE_ORIGIN${SITE_PREFIX%/}/" > /dev/null

          npx --yes sireg@1.1.0 check \
            --sitemap "$PRODUCTION_SITEMAP" \
            --origin "$SITE_ORIGIN" \
            --strategy random --limit 25 --seed "$PR_HEAD_SHA" \
            --expect-status 200 --max-redirects 0 \
            --report console --html reports/sireg.html
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: sireg-report
          path: reports/sireg.html
          if-no-files-found: ignore

See coverage and committed suites for full runs, artifact settings, and required checks.