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:
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@v1PR 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.
- 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: errorInputs
| Input | Default | Description |
|---|---|---|
working-directory | . | Directory to scan |
fail-on | error | When to fail: error | warning | off |
min-score | 0 | Minimum health score required to pass, from 0 to 100 |
comment | true | Post/update a sticky PR comment with the report |
diff-only | true | Report only diagnostics introduced by the PR |
json-report | empty | Path to write a JSON report; leave empty to skip |
sarif-report | empty | Path to write a SARIF 2.1.0 report; leave empty to skip |
upload-sarif | false | Upload findings to GitHub Code Scanning; requires security-events: write |
Outputs
| Output | Description |
|---|---|
total | Total number of diagnostics |
errors | Number of error-severity diagnostics |
warnings | Number of warning-severity diagnostics |
score | Health score (0–100) |
score-label | Letter grade (S, A–F) |
Enforcing a minimum score
- uses: santi020k/astro-doctor@v1
with:
fail-on: off
min-score: 80PR comment format
When comment: true, the action posts a comment like:
## 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.