# Keep architecture diagrams current with a GitHub Action

This guide is for teams that keep diagram files in a GitHub repository. With the open-diagram GitHub Action, every push checks or redraws those files, and a layout problem fails the run.

## What does the Action do?

It installs open-diagram, then runs the check on every file you list, or draws each one. The files can be JSON (`.json`), Mermaid (`.mmd` or `.mermaid`) or Python scripts with a `build()` function (`.py`).

## How do I add it?

Add one workflow file, which tells GitHub what to run and when.

1. Put your diagram files in one folder, such as `docs/diagrams/`.
2. If you keep a states file, put it outside that folder, such as `docs/states.json`.
3. Add this file to the repository as `.github/workflows/diagrams.yml`:

   ```yaml
   # .github/workflows/diagrams.yml
   name: diagrams
   on: [push, pull_request]
   jobs:
     diagrams:
       runs-on: ubuntu-latest
       steps:
         - uses: actions/checkout@v4
         - uses: lukendeasy/open-diagram@v0.6.2
           with:
             files: docs/diagrams/*.json docs/diagrams/*.mmd
             statuses: docs/states.json   # optional
             mode: check                  # or draw, to write SVG and PNG next to each file
   ```

4. Push the change.

Step 2 matters because `docs/diagrams/*.json` matches every JSON file in that folder. The Action reads a states file there as a diagram, and the check stops with `unknown key(s) 'Fraud checks', 'Parcel lockers'`.

## Which settings does it take?

Four, and only `files` is required.

| Input | Required | What it does |
| --- | --- | --- |
| `files` | Yes | The diagram files, separated by spaces or new lines. Patterns such as `*.json` and `**` work |
| `mode` | No | `check` (the default) or `draw` |
| `statuses` | No | A JSON file of names and states, applied before each diagram is built |
| `python-version` | No | The Python version to use; `3.12` by default |

A pattern that matches no file fails the run with `no files match 'docs/missing/*.json'`. Any mode other than `check` or `draw` fails it too.

## Should I use check mode or draw mode?

Use check mode when you only need to know that every diagram has 0 layout problems, and draw mode when the job also needs the pictures. Check mode builds each diagram in memory, lists its problems and writes nothing. Draw mode also writes an SVG and a PNG next to each file. The Action does not commit or upload them. To keep them, add your own step after it.

A PNG needs Chrome, Chromium or Edge on the machine that runs the job, and the Action installs none. Without a browser, `draw` writes the SVG, prints `PNG skipped: Chrome, Chromium or Edge was not found (set the CHROME environment variable to its path)`, and passes if the layout has no problems.

## What does a failing run show?

In check mode, the same lines `open-diagram check` prints on your own computer. This local run covers two files, one with a crowded line label:

```text
$ open-diagram check docs/diagrams/*.json docs/diagrams/*.mmd
docs/diagrams/plan.json: 2 layout problem(s)
  - the label 'pickup orders' on line 'orders' -> 'lockers' sits on 'orders'
  - the label 'pickup orders' on line 'orders' -> 'lockers' sits on 'lockers'
docs/diagrams/returns.mmd: 0 layout problem(s)
```

The command exits with 1, and the step fails. The [layout problem pages](../problems.html) explain each message and its fix.

## How does the Action use a states file?

It applies one states file to every file it checks. For example:

```json
{"Fraud checks": "live", "Parcel lockers": "building"}
```

Names match panel titles, panel ids and tile labels. When work ships, change one word and push.

Each name must match a part in every file the Action checks. If one file has no part called "Fraud checks", the run stops with `no panel or tile is named 'Fraud checks'`. In check mode, the files after it are not checked. [Show live and planned work](show-live-and-planned-work.html) covers the states themselves.

Updated November 25, 2026. Web page: https://open-diagram.dev/guides/keep-diagrams-current.html

See also:

- [Show live and planned work on an architecture diagram](https://open-diagram.dev/guides/show-live-and-planned-work.md)
- [Put architecture diagrams in slides, docs and GitHub READMEs](https://open-diagram.dev/guides/diagrams-in-slides-docs-and-readmes.md)
- [Draw diagrams without Python: write JSON from any language](https://open-diagram.dev/guides/json-from-any-language.md)
