Skip to content

Instantly share code, notes, and snippets.

@scorpp
Created May 30, 2025 16:46
Show Gist options
  • Save scorpp/3efbf1ef817f9592124709bbb1c08b95 to your computer and use it in GitHub Desktop.
Save scorpp/3efbf1ef817f9592124709bbb1c08b95 to your computer and use it in GitHub Desktop.
PlantUML rendering GitHub Action

Rendering PlantUML with GitHub Actions

None of existing GitHub Actions is perfect, most are outdated, others use PlantUML Server, which doesn't work well for private repos.

What's included

  • Flow triggers for *.puml file changes only
  • Uses latest PlantUML docker image (but version could be adjusted)
  • Allows you to customise any aspect of rendering by adjusting CLI args
  • Commits rendered images automatically in a separate commit

That's all was made possible by using nice tj-actions/docker-run action.

name: Generate PlantUML Diagrams
on:
push:
paths:
- "**.puml"
jobs:
plant-uml:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch whole repo history
- name: Get all changed markdown files
id: changed-files
uses: tj-actions/changed-files@v46 # v46
with:
# Avoid using single or double quotes for multiline patterns
files: |
**.puml
- name: Generate Diagrams
uses: tj-actions/[email protected]
if: steps.changed-files.outputs.any_changed == 'true'
with:
image: ghcr.io/plantuml/plantuml:latest
name: plantuml
options: '-v ${{ github.workspace }}:/data'
args: |
-tsvg -v ${{steps.changed-files.outputs.all_changed_files}}
- name: Push Local Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "${{ github.event.head_commit.message }} - Puml"
branch: ${{ github.head_ref }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment