Skip to content

Preview pull requests

Build a viewer site per pull request, opened on Compare from the base branch to the pull request, and comment the Changes on it.

To see what CI will build, fetch the base branch, then build the preview from your pull request’s branch:

Terminal window
git fetch origin main
archidocs build --preview --base main --out preview
Wrote the preview site to preview: Compare origin/main (83d7816) → PR (783c53a)

Archidocs reads the base from origin/<base> and never fetches it. The flags are in the archidocs build reference.

On GitHub, add a workflow that runs the Action with preview: true. It uploads the preview as the archidocs-preview workflow artifact:

.github/workflows/architecture-preview.yml
name: Architecture preview
on: pull_request
permissions:
contents: read
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: chalharb/archidocs@v1
id: archidocs
with:
preview: true

On GitLab, skip this step: the template’s archidocs-preview job builds a preview on every merge request.

3. Deploy it where reviewers can browse it

Section titled “3. Deploy it where reviewers can browse it”

Skip this step if reviewers download the artifact. GitHub Pages can’t host a site per pull request, so deploy the Action’s site output to a host that can:

  • Netlify: netlify deploy --dir "$SITE" --alias "pr-$PR_NUMBER".
  • Cloudflare Pages: wrangler pages deploy "$SITE" --project-name <project> --branch "pr-$PR_NUMBER".
  • An S3-style bucket: sync it under a prefix, such as s3://<bucket>/pr/<n>/.

archidocs diff --format markdown writes the Changes as a table. Archidocs posts nothing itself, so post it as your CI user. On GitHub, add this job to the preview workflow:

.github/workflows/architecture-preview.yml
comment:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
- run: npm install --global archidocs
- name: Comment the architecture changes
env:
GH_TOKEN: ${{ github.token }}
BASE: ${{ github.base_ref }}
PR: ${{ github.event.pull_request.number }}
run: |
archidocs diff "origin/$BASE" HEAD --format markdown > architecture.md
# Edit the comment this job posted before, or post one.
gh pr comment "$PR" --body-file architecture.md --edit-last --create-if-none

On GitLab, post architecture.md with the Notes API and a project access token.

Open a pull request that changes the Model. The comment lists each Change:

### Model changes `origin/main (83d7816)` → `HEAD (783c53a)`
2 added, 0 removed, 0 changed.
| Change | Kind | Id | Fields |
| --- | --- | --- | --- |
| added | Element | `payments:payments-cache` | |
| added | Relationship | `payments:payments-service -> payments:payments-cache` | |

Open the preview: it starts on the C2 Landscape with Compare “base → PR” on, and the added Elements marked.

The build stops when the base branch isn’t in the checkout:

archidocs: origin/develop is not in this checkout; fetch the base branch before building (archidocs never fetches).

Check out with fetch-depth: 0, or run git fetch origin <base> first.

If everything shows as added, the base branch has no Workspace yet. Compare then starts from an empty Model, which is expected for the first pull request.

Documents the beta branch at cd98671, ahead of the latest release, v1.4.0.