-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (116 loc) · 4.51 KB
/
RenderAllDiagrams.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Render All Diagrams
on:
push:
paths:
- '**/Material/images/src/**/*.puml'
- '**/Material/images/src/**/*.drawio'
- '**/Material/images/src/**/*.bpmn'
branches-ignore:
- 'main**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repository
uses: actions/checkout@v4
# Installs Java distribution for running the plantUML jar
- name: Install Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
check-latest: true
# Install graphviz for plantuml
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
# Download plantUML jar
- name: Download plantuml file
run: |
wget -O plantuml.jar "https://github.com/plantuml/plantuml/releases/latest/download/plantuml.jar"
# Ensure Folder exsists, otherwise, create it
- name: Ensure and clean folder
run: |
img_dir=Material/images/diagrams
mkdir -p $img_dir
# do not clean
# rm -rf Material/images/diagrams/*.svg
# Generate the SVGs from PUML
- name: Render PUML to SVG files
run: |
FileNamePaths=$(find . -path "*/images/src/*/*.puml" -exec dirname {} \; | sort -u)
for dir in $FileNamePaths
do
# Render SVGs from PUMLs
find $dir -name "*.puml" -exec java -jar plantuml.jar -tsvg {} \;
done
# Remove plantUML jar
- name: remove plantuml file
run: |
rm -f plantuml.jar
# Generate the SVGs from DrawIO
- name: Render DrawIO to SVG with predefined action
uses: rlespinasse/drawio-export-action@v2
with:
path: ./Material/images/src/drawio/
remove-page-suffix: true
output: .
format: svg
action-mode: all
# Install note.js and bpmn-to-image
- name: Install Notejs and pbmn-to-image
uses: actions/setup-node@v4
with:
node-version: 18
- run: npm install -g bpmn-to-image
# Generate the SVGs from BPMN
- name: Render BPMN to SVG files
run: |
FileNamePaths=$(find . -path "*/images/src/*/*.bpmn" -exec dirname {} \; | sort -u)
for dir in $FileNamePaths
do
# Render SVGs from BPMN
echo $dir
FileBaseNames=$(find $dir -name "*.bpmn" -exec basename "{}" ".bpmn" \; | sort -u)
#FileBaseNames=$(find $dir -name "*.bpmn" | xargs -L1 -I{} basename "{}")
for base in $FileBaseNames
do
echo $base
bpmn-to-image "$dir/$base.bpmn":"$dir/$base.svg";
done
done
# copies the created SVG files to the images/diagrams folder and deletes the drawio files
# mv for copy and delete, here
- name: Move SVGs to target image folder
run: |
img_dir=Material/images/diagrams
# Find all unique directories containing *.SVGs files under any /imgsrc/ folder
FileNamePaths=$(find . -path "*/images/src/*/*.svg" -exec dirname {} \; | sort -u)
for dir in $FileNamePaths
do
# Move SVGs to out directory
# find $dir -name "*.svg" -exec rm -rf {} $img_dir \;
find $dir -name "*.svg" -exec mv -f {} $img_dir \;
done
## add and commit the new generated files
#- name: Create Pull Request
# uses: peter-evans/create-pull-request@v5
# with:
# branch: auto/images-generation
# commit-message: Generated Images from source Code by GitHub Action
# title: Generated Images from GitHub Action
# assignees: ${{ github.actor }}
# reviewers: ${{ github.actor }}
# delete-branch: true
# labels: automated pr
- name: Commit rendered files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_user_name: GitHub Actions Bot
commit_user_email: [email protected]
commit_message: auto-generated diagrams by GitHub Action after source code change
- name: "Run if no changes have been detected"
if: steps.auto-commit-action.outputs.changes_detected == 'false'
run: echo "No Changes!"