Prompt
How do I build a docs workflow where code changes update the portal automatically?
Latest observation
A good pattern is to make your docs site the source of truth for rendered docs, while code changes trigger a docs build + publish automatically. Here’s a practical workflow you can implement.
1) Decide what “updates the portal automatically” means
Usually one of these:
- Docs are generated from code (API docs, OpenAPI, JSDoc, Sphinx, MkDocs, etc.)
- Docs content lives with code and changes are deployed whenever the repo changes
- A portal aggregates docs from multiple repos/services and redeploys on updates
The workflow is similar in all cases:
- developer changes code or doc source
- CI runs tests + doc generation/build
- artifacts are published to a docs host
- portal refreshes or redeploys
2) Recommended architecture
Option A: Single repo, docs in same repo
Best if code and docs are tightly coupled.
Flow
- PR changes code or markdown
- CI builds docs
- preview docs are deployed for the PR
- merge to main triggers production docs deploy
Common tools
- MkDocs / Docusaurus / VitePress / Sphinx
- GitHub Actions / GitLab CI / CircleCI
- S3 + CloudFront, Netlify, Vercel, GitHub Pages, or an internal portal
Option B: Docs generated from code
Best for API-heavy projects.
Flow
- code changes modify annotations, schemas, or OpenAPI spec
- build pipeline extracts docs from code
- generated docs are published to portal
Common tools
- OpenAPI/Swagger, Redoc, Swagger UI
- JSDoc/TypeDoc for JS/TS
- Sphinx for Python
- Rustdoc, Go doc tools, JavaDoc, etc.
Option C: Central portal consuming multiple doc sources
Best for a platform with many services.
Flow
- each service repo publishes a versioned docs artifact
- central portal pulls latest approved versions
- portal indexes or links to them
Common tools
- docs-as-code in each repo
- artifact storage, static site hosting, or a docs aggregator
- search indexing if needed
3) Set up the docs build pipeline
Example CI stages
-
Lint/test
- code tests
- docs linting
- broken link checks
-
Generate docs
- extract API docs or compile site
-
Build site
- produce static HTML/assets
-
Publish
- upload to docs host or object storage
-
Notify / invalidate cache
- clear CDN cache or trigger portal refresh
4) A simple GitHub Actions example
If your docs are in the repo and you publish a static site:
name: Build and Deploy Docs
on:
push:
branches: [ main ]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build docs
run: npm run docs:build
- name: Upload preview artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: docs-preview
path: ./dist
deploy:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Build docs
run: npm run docs:build
- name: Deploy to static host
run: npm run docs:deploy
5) If the portal is separate from the repo
You can still automate it.
Pattern
- repo builds docs and publishes an artifact
- portal watches artifact storage or receives a webhook
- portal reindexes/rebuilds
Examples
- push static files to S3
- trigger CDN invalidation
- call a portal API endpoint like
/rebuild-index - publish versioned docs to an internal package registry or artifact store
6) Make updates reliable
Use versioning
- publish docs per release:
v1.4.2,v1.5.0 - keep a
latestalias - avoid breaking old docs when new releases ship
Add previews for PRs
- every PR gets a temporary docs preview URL
- reviewers can see the docs impact before merge
Gate deployments
- only publish on passing tests
- require docs build to succeed before merge
- add link checks and API spec validation
Automate generated docs
If documentation is derived from code:
- keep source comments/annotations close to code
- generate docs in CI, not manually
- fail builds if generated docs are outdated
7) Recommended setup by stack
For static docs site
- Docs framework: Docusaurus / MkDocs / VitePress
- CI: GitHub Actions
- Deploy: Netlify, Vercel, S3, or GitHub Pages
For API docs
- Source: OpenAPI spec or annotations
- Renderer: Redoc / Swagger UI
- CI: generate spec, validate, publish
For enterprise portal
- Sources: multiple repos
- Orchestration: CI publishes artifacts + webhook to portal
- Indexing: search sync on deploy
8) Best practices
- Treat docs like code: review, test, version, deploy
- Build docs on every PR
- Keep generation deterministic
- Validate links and code samples
- Separate draft docs from published docs
- Record which code version produced which docs version
9) A practical minimal implementation
If you want the simplest working version:
- Put docs in the repo using MkDocs or Docusaurus
- Add a
docs:buildscript - Configure CI to run on every push/PR
- Deploy main branch to your docs host
- Use PR preview builds for review
If you tell me your stack (GitHub/GitLab, docs tool, cloud host, and whether docs are generated from code or written manually), I can sketch the exact workflow and CI config for your setup.