Quick answer: Auto-refreshing OpenAPI in CI means the hosted documentation updates itself from the spec instead of waiting for someone to remember a manual upload. The setup that holds up is two stages: the pull request runs lint and a breaking-change diff as a hard gate, and the merge to main triggers the refresh, with the spec kept as the single source of truth. Done that way, the docs track the API and a malformed or breaking change cannot reach readers.
Why manual refresh drifts
Docs drift when the spec and the published page live in separate workflows. A change lands on the endpoint, a separate "update the docs" ticket gets opened, and the ticket slips a release. The page then describes an operation that no longer exists, and readers trust the wrong contract.
The fix is a rule rather than a reminder: if it is not in the spec, it is not the API. Every code change that affects the API shape carries the OpenAPI update in the same pull request, and structural details such as endpoints, parameters, schemas, and responses are derived from the spec rather than retyped by hand. Narrative prose can still live in Markdown, but the contract surface has one owner. When the merge itself is the event that refreshes the page, there is no manual step left to forget.
The two-stage CI flow
The same pipeline does two different jobs depending on the event. On a pull request it protects the main branch; on a push to main it publishes.
| Stage | Trigger | Checks | Outcome |
|---|---|---|---|
| Gate | Pull request | Lint, validate, bundle, breaking diff | Blocks merge on failure |
| Publish | Push to main | Build and refresh hosted docs | New version goes live |
| Filter | Both events | Run only when the spec path changes | Saves CI time |
A paths filter on the workflow means unrelated pull requests do not pay for an API check, and the publish job runs only after the gate has passed. Splitting the two jobs also keeps a failed publish from looking like a failed review; the team knows which step needs attention.
What the PR gate must catch
A validator that confirms the document is well-formed does not confirm it is safe. A spec can parse cleanly and still break every client that depended on a field renamed during a refactor. The only way to see that change is to compare the new spec against the version it replaces.
Run an OpenAPI diff against the published baseline and set it to fail on breaking errors, so a removed response field or a tightened parameter blocks the merge. To read the baseline in CI, fetch the full history and pull the target branch's spec with a git show, rather than comparing against an empty file. Lint handles style and structure, while the diff handles compatibility; the two checks answer different questions and neither replaces the other.
How hosted docs refresh on merge
Once the pull request merges, the main-branch job builds the output and refreshes the hosted page without anyone opening a dashboard. The refresh should produce a new version rather than overwriting the old one, so the change can be reviewed after the fact and rolled back if it was wrong.
In Powerduck Cloud, you can point a document at a Git repository, and Git sync flows repository updates into a new hosted version after the merge, with each version carrying a diff and rollback and the original file left untouched. That removes the manual re-upload while keeping a clear history of what changed and when.
Frequently asked questions
Does auto-refresh mean breaking changes deploy automatically? No. The breaking-change diff runs on the pull request and blocks the merge, so a breaking change cannot reach the publish stage unless the gate passes or the team deliberately overrides it with a new major version.
Do I need a separate account for every reader? No. Public readers use a dedicated viewer without an account, and the page is gated only if you set a view password. The CI refresh is a publishing step, not a reader sign-in.
What happens if the publish job fails after the merge? The gate result stays valid and the spec remains correct, so the job can be retried against the same merge. Because the refresh is idempotent by version, retrying does not create duplicate posts or alter the contract.
The bottom line
Stop treating documentation refresh as a task a person has to remember. Make the spec the one owner of the contract, hold every pull request to lint plus a breaking diff, and let the merge to main drive the hosted page as a new version with rollback. The teams that avoid drift are not the ones with the strictest style guide; they are the ones that removed the manual step entirely. For a wider look at how hosted platforms handle Git-driven publishing, see the docs platform comparison hub.
Top comments (0)