MkDocs Workflow
Purpose
Define the single source of truth for private documentation hosting, MkDocs authoring workflow, and deployment operations.
Requirements
- Access must be private (explicit allow-list only).
- Authentication must support personal Google accounts.
- Docs must be readable on mobile.
- Production docs deployment must be CI/CD-only.
Decision
- Hosting: Cloudflare Pages.
- Access control: Cloudflare Access.
- Identity provider: Google IdP.
- Deployment model: CI/CD workflow from repository.
Why this approach: - Lower operational overhead than AWS S3 + CloudFront + custom auth layers. - Fast setup for private docs with explicit user-level access policies.
Source of truth files
- MkDocs config:
mkdocs.yml - Docs content:
docs/ - Docs dependency input:
docs/requirements.in - Docs dependency lock:
docs/requirements.txt - Deployment workflow:
.github/workflows/docs-deploy.yml
Quick commands
# install dependencies
python -m pip install --upgrade pip
python -m pip install -r docs/requirements.txt
# serve locally
mkdocs serve -a 127.0.0.1:8080
# validate before PR
mkdocs build --strict --site-dir site
Security rules (non-negotiable)
- Production docs deploy only from CI.
- Do not deploy production docs from a local machine.
- Do not use dashboard drag-and-drop for production.
- Keep Access policy explicit allow-list only (no wildcard include rules).
Local authoring loop
- Edit docs under
docs/. - Install docs dependencies:
bash python -m pip install --upgrade pip python -m pip install -r docs/requirements.txt - Run local docs server:
bash mkdocs serve -a 127.0.0.1:8080 - Validate build:
bash mkdocs build --strict --site-dir site
Updating docs dependencies
Use pip-tools when adding or changing MkDocs plugins/packages.
- Update
docs/requirements.in. - Recompile lock file:
bash python -m pip install --upgrade pip python -m pip install pip-tools pip-compile docs/requirements.in --output-file docs/requirements.txt - Re-run strict build:
bash mkdocs build --strict --site-dir site
Current base packages in docs/requirements.in:
- mkdocs
- mkdocs-mermaid2-plugin
Editing and publishing flow
- Update content under
docs/. - If adding/changing docs packages, update
docs/requirements.inand recompiledocs/requirements.txt. - Run local strict validation.
- Open PR and let CI validate/deploy according to
.github/workflows/docs-deploy.yml. - After merge to
main, verify production docs access and content atdocs.byteraccoon.com.
Cloudflare Access and Pages setup
- Create or use a Pages project for docs.
- Bind custom domain
docs.byteraccoon.com. - Create Access application for
docs.byteraccoon.com. - Configure Google IdP in Cloudflare Access.
- Enforce policy:
- Include only explicit users/groups.
- Remove wildcard (
*) include rules. - Keep default deny behavior.
CI/CD deployment flow
- Trigger: push to
maintouching docs workflow paths, or manualworkflow_dispatch. - Build:
mkdocs build --strict --site-dir site. - Deploy: Cloudflare Pages via
cloudflare/wrangler-action@v3. - AuthZ/AuthN: Cloudflare Access + Google IdP at
docs.byteraccoon.com.
Required GitHub environment secrets:
- CF_API_TOKEN
- CF_ACCOUNT_ID
- CF_PAGES_PROJECT
Validation
- Confirm CI workflow succeeded for latest docs change on
main. - Confirm
docs.byteraccoon.compresents Google login. - Confirm allowed users can access docs.
- Confirm non-allowed users are denied.
Operations
- Onboard user: add to Access allow-list and verify login.
- Offboard user: remove from Access allow-list immediately.
- Rotate
CF_API_TOKENon schedule and after personnel changes. - Keep branch protection on
main.
Rollback
- Revert docs commit on
main. - Let CI publish the reverted docs version.
- Apply temporary deny-all Access policy if incident response requires it.
Troubleshooting
- If
mkdocs build --strictfails on Mermaid URL checks in offline/restricted networks, verify with:bash mkdocs build --site-dir siteThen rerun strict mode in a network-enabled environment (CI or local network with internet access).
References
- Cloudflare Access with Google IdP: https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/google/
- Cloudflare Pages CI direct upload: https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/
- Cloudflare Access product: https://www.cloudflare.com/zero-trust/products/access/
- S3 website access constraints: https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteAccessPermissionsReqd.html