Skip to content
PageAudit

Audit SEO in GitHub Actions with PageAudit

A workflow step audits your page after each push and fails the job when the page has an SEO error. No key needed.

Updated

1Add the workflow

Save the file as .github/workflows/seo-audit.yml and set PAGE_URL to your page.

name: SEO audit
on:
  push:
    branches: [main]
  workflow_dispatch:
jobs:
  pageaudit:
    runs-on: ubuntu-latest
    env:
      PAGE_URL: https://example.com/
    steps:
      - name: Audit the page with PageAudit
        run: |
          status=$(curl -sS -o report.json -w '%{http_code}' -X POST https://pageaudit.online/api/audit \
            -H 'content-type: application/json' -d "{\"url\": \"$PAGE_URL\"}")
          STATUS=$status python3 - <<'PY'
          import json, os, sys
          status = os.environ["STATUS"]
          report = json.load(open("report.json"))
          if status in ("402", "429"):
              print("::warning::No free PageAudit audits left today.")
              sys.exit(0)
          if status != "200":
              print(f"::error::PageAudit answered {status}: {report.get('error')}")
              sys.exit(1)
          counts = report["counts"]
          print(f"Score {report['score']}: {counts['errors']} errors, {counts['warnings']} warnings")
          for issue in report["issues"]:
              if issue["severity"] == "error":
                  print(f"::error::{issue['code']}: {issue['message']}")
          sys.exit(1 if counts["errors"] else 0)
          PY

2Run the workflow

Push to main or click Run workflow in the Actions tab. The log shows the score, and each SEO error comes as an annotation. When the free audits of the day are used up, the step warns and passes.

3See the fix

Audit the same page in PageAudit to see the evidence and the suggested change for each error.