Skip to content

GitHub Action

The santi020k/astro-doctor composite action scans your Astro project in CI, posts a sticky PR comment with the health score, and fails the check when issues are found.

Minimal setup

Create .github/workflows/astro-doctor.yml:

yaml.github/workflows/astro-doctor.yml
name: Astro Doctor
on:
  pull_request:
    paths: ['**/*.astro']

jobs:
  scan:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write   # needed to post PR comments
      security-events: write # needed only when upload-sarif is true
    steps:
      - uses: actions/checkout@v7
      - uses: santi020k/astro-doctor@v1

PR diff mode (recommended)

With diff-only: true the action scans changed Astro files at the base and head revisions, then reports only diagnostics introduced by the pull request. Existing findings in touched files do not fail the new change.

yaml
- uses: actions/checkout@v7
  with:
    fetch-depth: 0        # required for diff detection
- uses: santi020k/astro-doctor@v1
  with:
    diff-only: true
    comment: true
    fail-on: error

Inputs

InputDefaultDescription
working-directory.Directory to scan
fail-onerrorWhen to fail: error | warning | off
min-score0Minimum health score required to pass, from 0 to 100
commenttruePost/update a sticky PR comment with the report
diff-onlytrueReport only diagnostics introduced by the PR
json-reportemptyPath to write a JSON report; leave empty to skip
sarif-reportemptyPath to write a SARIF 2.1.0 report; leave empty to skip
upload-sariffalseUpload findings to GitHub Code Scanning; requires security-events: write

Outputs

OutputDescription
totalTotal number of diagnostics
errorsNumber of error-severity diagnostics
warningsNumber of warning-severity diagnostics
scoreHealth score (0–100)
score-labelLetter grade (S, A–F)

Enforcing a minimum score

yaml
- uses: santi020k/astro-doctor@v1
  with:
    fail-on: off
    min-score: 80

PR comment format

When comment: true, the action posts a comment like:

markdown
## Astro Doctor 🟢 85/100 (B) _(introduced issues only)_

| | File | Location | Message | Rule |
|---|---|---|---|---|
| 🔴 | `src/pages/blog.astro` | 12:5 | img element is missing a non-empty alt attribute | `no-missing-alt` |
| 🟡 | `src/components/Counter.astro` | 3:1 | prefer client:idle or client:visible over client:load | `no-client-load-overuse` |

**1 error, 1 warning** across 14 files

<sub>Powered by [Astro Doctor](https://github.com/santi020k/astro-doctor)</sub>

The comment is updated (not re-created) on every push. It uses a hidden HTML marker to identify the existing comment.