diff --git a/.github/workflows/GeneratePlantumlImages.yml b/.github/workflows/GeneratePlantumlImages.yml deleted file mode 100644 index 88b11ee5..00000000 --- a/.github/workflows/GeneratePlantumlImages.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: GeneratePlantumlImages - -on: - push: - branches: - - '**' - paths: - - 'src/plantuml/**' - - 'src/drawio/**' - - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - # Installs Java distribution for running the plantUML jar - - name: Install Java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '11' - check-latest: true - - # Install graphviz for plantuml - - name: Setup Graphviz - uses: ts-graphviz/setup-graphviz@v1 - - # Download plantUML jar - - name: Download plantuml file - run: | - wget -O plantuml.jar "https://github.com/plantuml/plantuml/releases/download/v1.2023.10/plantuml-1.2023.10.jar" - - # Runs a single command using the runners shell - - name: Generate images - run: | - imagedir=images/diagrams - mkdir -p $imagedir - rm -rf images/diagrams/* - for fullname in $(find src/plantuml/ -type f -name '*.puml') - do - echo "Fullname: ${fullname}" - base=$(basename "${fullname}" .puml) - dir=$(dirname $fullname) - echo "Basename: ${base}" - outdir=$(dirname $fullname | sed s+src/plantuml+${imagedir}+) - echo "Outdir: ${outdir}" - mkdir -p $outdir - plantoutdir="${PWD}/${outdir}" - echo "PlantOutdir: ${plantoutdir}" - - # PlantUML arguments: - # -v for verbose output (Debugging) - # -checkmetadata checks whether the target png/svg has the same source - # and if there are no changes, doesn't regenerate the image file - # -o sets the output folder for the png/svg files - plantargs="-v -checkmetadata -o ${plantoutdir} ${fullname}" - - # separate calls are needed, because only one file type can be set - # per call - java -jar plantuml.jar -tpng ${plantargs} - java -jar plantuml.jar -tsvg ${plantargs} - - # method with pipes - #cat "${fullname}" | java -jar plantuml.jar -p -tpng -checkmetadata > "${outdir}/${base}.png" - #cat "${fullname}" | java -jar plantuml.jar -p -tsvg -checkmetadata > "${outdir}/${base}.svg" - done - tree ./images - - # creates png files from draw io image files - - name: Export drawio files as png - uses: rlespinasse/drawio-export-action@v2 - with: - path: ./src/drawio/ - output: . - format: png - action-mode: all - - # creates svg files from draw io image files - - name: Export drawio files - uses: rlespinasse/drawio-export-action@v2 - with: - path: ./src/drawio/ - output: . - format: svg - action-mode: all - - # copies the created png & svg files to the images/diagrams folder and deletes the drawio files - - name: Copy draw io - run: | - imagedir=images/diagrams - cp -RT ./src/drawio $imagedir - find $imagedir -name '*.drawio' -exec rm -rv {} \; - tree ./images - - # add and commit the new generated files - - name: Add & Commit - uses: EndBug/add-and-commit@v9 - with: - add: 'images/diagrams/' diff --git a/.github/workflows/generate-images.yml b/.github/workflows/generate-images.yml new file mode 100644 index 00000000..b4e8bd86 --- /dev/null +++ b/.github/workflows/generate-images.yml @@ -0,0 +1,76 @@ +name: Generate PlantUML & draw.io images + +on: + push: + branches: + - '**' + # paths: + # - 'src/plantuml/**' + # - 'src/drawio/**' + + workflow_dispatch: + +env: + PLANTUML_VERSION: 1.2024.4 + DRAWIO_VERSION: 24.2.5 + PLANTUML_SRC: src/plantuml + DRAWIO_SRC: src/drawio + OUTDIR: images/diagrams + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + check-latest: true + + - name: Set up Graphviz, Xvfb & draw.io desktop + run: | + wget -q https://github.com/jgraph/drawio-desktop/releases/download/v${{ env.DRAWIO_VERSION }}/drawio-amd64-${{ env.DRAWIO_VERSION }}.deb + sudo apt-get update + sudo apt-get install --yes --no-install-recommends graphviz xvfb ./drawio-amd64-${{ env.DRAWIO_VERSION }}.deb + + - name: Download PlantUML JAR + run: | + # Ironically, manually fetching the JAR is faster than installing the Debian plantuml package + wget -O plantuml.jar "https://github.com/plantuml/plantuml/releases/download/v${{ env.PLANTUML_VERSION }}/plantuml-${{ env.PLANTUML_VERSION }}.jar" + + - name: Prepare output folder + run: | + rm -rf "${{ env.OUTDIR }}" + mkdir -p "${{ env.OUTDIR }}" + + - name: Export PlantUML files as png / svg + run: | + for ext in png svg; do + java -jar plantuml.jar -t$ext -v -nometadata -failfast2 -nbthread auto -o "." "${{ env.PLANTUML_SRC }}/**.puml" + rsync -v --recursive --include="*.$ext" --filter="-! */" "${{ env.PLANTUML_SRC }}"/* "${{ env.OUTDIR }}" + done + - name: Export draw.io files as png / svg + run: | + # draw.io desktop requires a running X server + export DISPLAY=:42 + Xvfb :42 -nolisten unix & + + for ext in png svg; do + # The chromium args need to be specified last because of whatever + drawio --export --recursive --format $ext "${{ env.DRAWIO_SRC }}" --no-sandbox --disable-gpu --disable-dev-shm-usage + + rsync -v --recursive --include="*.$ext" --filter="-! */" "${{ env.DRAWIO_SRC }}"/* "${{ env.OUTDIR }}" + + # Nuke the exported files so that draw.io desktop doesn't attempt to use them as input files on the next loop pass + find "${{ env.DRAWIO_SRC }}" -name "*.$ext" -exec rm -v "{}" \; + done + + - name: Add & Commit + uses: EndBug/add-and-commit@v9 + with: + add: ${{ env.OUTDIR }}