Run dxb checks and pushes in CI
Validate docs on every pull request and publish them on merge with dxb, an access token, --yes, --json and stable exit codes.
Set up a continuous integration (CI) pipeline that validates your docs on every pull request and publishes them to Doxbrix when changes merge. At the end, a failing lint or documentation check blocks the merge, and a merge to your main branch updates the live site without anyone running dxb by hand.
Use this guide when your docs live as local files in a repository and you push them with dxb. If you want Doxbrix to sync with the repository directly instead, see Sync a project with a Git repository.
Before you begin
- A local docs project that is already linked to a Doxbrix project, with
.doxbrix/config.jsoncommitted to the repository. See Tutorial: author docs locally with dxb. - A CI system that runs Node.js 22 or later, such as GitHub Actions or GitLab CI.
- Permission to add secret variables to the CI project.
How dxb behaves in CI
Four behaviors matter in a pipeline:
- Authentication comes from the environment.
dxbreads a token from--token, thenDOXBRIX_TOKEN, then a saved profile. In CI, setDOXBRIX_TOKENand don't rundxb login. - Prompts don't wait. When stdin or stderr is not a terminal, every yes/no confirmation takes its default answer, which is no. The command prints
Aborted.and exits with code 0, so the job looks successful even though nothing was published. Pass--yes(-y) to confirm prompts up front. - Machine-readable output goes to stdout. With
--json, a command writes one JSON document to stdout and human messages to stderr. On failure it writes{ "error": …, "code": …, "hint": … }to stdout unless the command already wrote its own report. - Exit codes are stable. Branch on them in scripts. See Exit codes.
Set up the pipeline
On a computer where you are signed in, create a token with only the scopes a push needs:
dxb auth token create "ci docs publish" \
--scopes docs:read --scopes docs:write --scopes project:read \
--expires-in-days 365The CLI prints ✓ Created token 'ci docs publish'. and Copy it now — it will not be shown again:, followed by the dxb_… value. You can also create the token in the web app; see Create and revoke access tokens.
Add the value as a masked secret named DOXBRIX_TOKEN:
- GitHub Actions: repository Settings > Secrets and variables > Actions > New repository secret.
- GitLab CI: project Settings > CI/CD > Variables, with Mask variable selected.
Never commit the token. .doxbrix/config.json never contains one, so it is safe to commit.
Run dxb lint --strict on every pull request. It exits with code 2 when there is any error or warning, which fails the job.
npx --yes @doxbrix/cli@latest lint --strictdxb lint needs no token or network access, so it is safe to run on pull requests from forks.
On pushes to the main branch, validate and then publish:
npx --yes @doxbrix/cli@latest push --publish --yes --strict--yes answers the Publish N page(s)? confirmation, and --strict fails the push if any file is missing from docs.json instead of silently skipping it. dxb push also refuses to upload while lint errors remain, printing Refusing to push: N lint error(s).
Add the pipeline definition to the repository. Choose your CI system:
Save as .github/workflows/docs.yml:
name: Docs
on:
pull_request:
push:
branches: [main]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install --global @doxbrix/cli
- run: dxb lint --strict
publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: check
runs-on: ubuntu-latest
env:
DOXBRIX_TOKEN: ${{ secrets.DOXBRIX_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install --global @doxbrix/cli
- run: dxb whoami
- run: dxb push --publish --yes --strictThe dxb whoami line fails fast with exit code 3 if the token is missing or revoked, before any upload starts.
Push a branch with a small docs change and open a pull request. The check job runs dxb lint --strict and shows ✓ No problems found. in the job log. Merge the pull request to run the publish job.
Verify
After the publish job finishes, its log ends with lines such as:
✓ Pushed 12 page(s): 0 created, 2 updated, 1 space(s).
→ Published pages, search, and AI are updated.Open the reader site and confirm your change is live. If the log shows Aborted. instead, the job ran without --yes and nothing was published.
Add the documentation check gate
dxb docs check is a stricter gate for teams that maintain a documentation brief. It combines lint, the brief and reader-coverage plan, page contracts, links, evidence receipts, source freshness and example verification. It needs no login or network access.
dxb docs check --source product=../product --base origin/main --strict| Option | Effect |
|---|---|
--source <[id=]path> | Product source root to check evidence against. Repeatable. |
--base <ref> | Also flags pages that may be affected by product changes since this Git revision. |
--head <ref> | Head revision for --base. Default: HEAD. |
--strict | Fails on warnings as well as errors. |
--run | Allows the configured example-verification commands to run. |
The check fails with exit code 2 and Documentation check failed with N error(s). if .doxbrix/documentation.json is missing, the brief is incomplete, or no reader-coverage row exists. Set these up once with dxb docs setup. With --json, the command writes a report whose ok, errors and warnings fields you can read in later steps:
dxb docs check --strict --json > docs-check.jsonExit codes
Every dxb command exits with one of these codes.
| Code | Meaning | Typical cause |
|---|---|---|
0 | Success | The command completed, or a confirmation was declined and printed Aborted. |
1 | General error | An unexpected API or local error. |
2 | Usage or validation error | Unknown flag, lint failure, Refusing to push, or a failed dxb docs check. |
3 | Authentication error | No token, a rejected token, or a token missing a required scope. |
4 | Plan entitlement | The plan doesn't include the feature. See Plans and limits reference. |
5 | Conflict or precondition | The request conflicts with the current server state. |
6 | Network or rate limit | The API is unreachable, or Rate limited. Retry in Ns. |
Retry only codes 5 and 6; the others need a change to the token, plan or files.
Troubleshooting
For more CLI problems, see Troubleshoot the CLI, Git sync and MCP.
