-
Notifications
You must be signed in to change notification settings - Fork 11
105 lines (89 loc) · 3.46 KB
/
GenerateImagesFromSrc.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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/'