← Documentation

CI integration (advanced)

Keep your diagrams automatically up to date: whenever a stored procedure changes, a CI job runs the CLI against the changed .sql files and commits the regenerated diagrams back to the repo alongside the source.

How it works

  1. The pipeline triggers on a push that touches your procedures folder (e.g. procs/**.sql).
  2. It installs bnl-diagrams as a dotnet tool, and works out which .sql files changed in that push.
  3. It runs bnl-diagrams against just those files, writing .mmd output into a diagrams/ folder.
  4. If anything changed, it commits and pushes the regenerated diagrams back using a bot identity - no manual step required.

Your API key needs to be stored as a secret in your CI system, never committed to the repo - see each sample below for exactly where it goes.

GitHub Actions

Add a repository secret named BNL_DIAGRAMS_API_KEY (Settings → Secrets and variables → Actions), then add this workflow:

regenerate-diagrams.yml

Azure DevOps Pipelines

Add a secret pipeline variable (or variable group) named BNL_DIAGRAMS_API_KEY, and enable "Allow scripts to access the OAuth token" on the pipeline so the commit-back step can push, then add this pipeline:

regenerate-diagrams-azure-pipelines.yml

Browsing the results

Once diagrams are committed to your repo on every change, our diagram viewer template gives you a simple, searchable way to browse them without needing to open each .mmd file individually.