“Our architecture diagram is out of date” is a universal team pain. Here’s how to use CI to bind diagrams to the codebase — auto-check, auto-rerender, staleness alerts, PR thumbnails.
The anti-pattern: draw a diagram and forget
1 2 3
docs/architecture/ flow.png # drawn in 2023, no one maintains it README.md
Six months later, services have been deprecated and new ones added. flow.png still shows 2023. Architecture diagrams live in a vacuum.
name:Checkdiagramstaleness on: schedule: -cron:'0 9 * * 1'# every Monday 9am
jobs: check: runs-on:ubuntu-latest steps: -uses:actions/checkout@v4 with: fetch-depth:0 -name:Finddiagramsolderthan6months run:| stale=$(find docs -name '*.puml' -mtime +180) if [[ -n "$stale" ]]; then echo "::warning::Stale diagrams (>180 days):" echo "$stale" exit 1 fi -name:Openissueifstale if:failure() uses:actions/github-script@v7 with: script:| const files = `$(find docs -name '*.puml' -mtime +180)`.trim(); await github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, title: '[stale] architecture diagrams older than 180 days', body: `Diagrams that need a review:\n\n\`\`\`\n${files}\n\`\`\`` });
Every Monday morning, any .puml untouched for 180 days auto-opens a stale review issue.
Trick 4: Force README to reference the diagrams
Unwanted drift:
1 2 3
# Project
See our architecture diagrams in Confluence.
CI lint:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
name:LintREADME on: pull_request: paths: -'README.md'
jobs: lint: runs-on:ubuntu-latest steps: -uses:actions/checkout@v4 -name:CheckREADMEreferencesrepodiagrams run:| if ! grep -q 'docs/architecture' README.md; then echo "::error::README.md must link to docs/architecture/" exit 1 fi
Force README to link to in-repo diagrams; ban the “diagrams live on external wiki” pattern.
Full workflow
Combine the four:
On push to main: CI auto-rerenders all SVG (stale = failed PR).
On PR: auto-comment with thumbnail SVGs (reviewers see the diff).