Skip to content

Instantly share code, notes, and snippets.

@scorpp
Created May 30, 2025 16:46
Show Gist options
  • Select an option

  • Save scorpp/3efbf1ef817f9592124709bbb1c08b95 to your computer and use it in GitHub Desktop.

Select an option

Save scorpp/3efbf1ef817f9592124709bbb1c08b95 to your computer and use it in GitHub Desktop.

Revisions

  1. scorpp created this gist May 30, 2025.
    10 changes: 10 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # 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.
    42 changes: 42 additions & 0 deletions github-workflows-pumlgen.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    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 }}