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
steps:
- uses: actions/checkout@v4
- uses: santi020k/astro-doctor@v1
PR diff mode (recommended)
With diff-only: true the action detects changed .astro files via
git diff and scans only those — making it fast even on large monorepos.
- uses: actions/checkout@v4
with:
fetch-depth: 0 # required for diff detection
- uses: santi020k/astro-doctor@v1
with:
diff-only: true
comment: true
fail-on: error
Inputs
| Input | Default | Description |
|---|---|---|
working-directory | . | Directory to scan |
fail-on | error | When to fail: error | warning | off |
comment | true | Post/update a sticky PR comment with the report |
diff-only | true | Scan only files changed in the PR |
json-report | empty | Path to write a JSON report; leave empty to skip |
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 (A–F) |
Using outputs in downstream steps
steps:
- uses: santi020k/astro-doctor@v1
id: doctor
with:
fail-on: off # don't fail here — handle below
- name: Check score threshold
run: |
SCORE=${{ steps.doctor.outputs.score }}
if [ "$SCORE" -lt 80 ]; then
echo "Score $SCORE is below threshold (80)"
exit 1
fi
PR comment format
When comment: true, the action posts a comment like:
## Astro Doctor 🟢 85/100 (B) _(changed files 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.
Permissions: The
pull-requests: write permission is only required
when comment: true. If you disable comments, this permission is not needed.