CLIGuides
GitHub Actions: publish on change
A minimal workflow that (a) lints on every PR, (b) publishes on pushes to `main` only when the spec actually changed.
A minimal workflow that (a) lints on every PR, (b) publishes on pushes to main only when the spec actually changed.
Auto-generate
spec0 ci generate github --spec-file openapi.yaml --branch main > .github/workflows/spec0.ymlOr write it directly to the suggested path:
spec0 ci generate github --spec-file openapi.yaml --writeSecrets
Configure two repository secrets:
SPEC0_TOKEN— fromspec0 auth token, or a machine-account token from the web app.SPEC0_ORG_ID— UUID of the org to publish into.
What the generated workflow does
- Installs
@spec0/cliglobally. - Lints on every PR — fails the check if
--min-scoreis not met. - On
pushtomain:- Runs
spec0 sync-statusto check whether the spec actually changed. - Skips
publishwhen the git SHA matches the last published version (cheap no-op). - Otherwise calls
spec0 publish --semverto publish and compute the next version.
- Runs
Troubleshooting
| Symptom | Check |
|---|---|
| Exit 3 / "not authenticated" | SPEC0_TOKEN / SPEC0_ORG_ID secrets not set, or token expired. |
| Exit 7 / lint below min score | Either fix the spec, lower --min-score, or adjust the org ruleset. |
| Exit 9 / server error, or 10 / network | Transient — re-run the job. If persistent, check status.spec0.io. |
| Exit 2 / usage | Flag typo or unknown CI provider. Run the command locally with --help. |
All exit codes are documented in the README.