Skip to content

Commit

Permalink
Create GenerateImagesFromSrc.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
gem-cp authored Dec 1, 2023
1 parent 16f139e commit 2203e0e
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/GenerateImagesFromSrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: GenerateImagesFromSrc

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/'

0 comments on commit 2203e0e

Please sign in to comment.