Skip to content

Commit bf9a54c

Browse files
committed
3333
1 parent 36cf926 commit bf9a54c

1 file changed

Lines changed: 33 additions & 22 deletions

File tree

.github/workflows/automatic_image_genration.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,29 @@ jobs:
121121
run: |
122122
echo "=== 🎨 Generating PlantUML images ==="
123123
124-
output_dir=${{ env.OUTPUT_DIR }}
124+
# Definitions
125+
rel_plantuml_input_dir="src/plantuml"
126+
output_dir="$(pwd)/images"
127+
plantuml_prefix="uml_"
128+
129+
echo "📁 Input directory: $rel_plantuml_input_dir"
125130
echo "📁 Output directory: $output_dir"
126131
127132
# Determine processing mode
128133
if [ "${{ github.event.inputs.regenerate_all }}" = "true" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
129134
echo "🔄 FULL REGENERATION MODE - Processing all files"
130-
puml_files=$(find ${{ env.REL_PLANTUML_INPUT_DIR }} -name "*.puml" -o -name "*.plantuml" 2>/dev/null)
135+
puml_files=$(find $rel_plantuml_input_dir -name "*.puml" -o -name "*.plantuml" 2>/dev/null)
131136
132137
if [ -z "$puml_files" ]; then
133-
echo "❌ No PlantUML files found in ${{ env.REL_PLANTUML_INPUT_DIR }}/"
138+
echo "❌ No PlantUML files found in ${rel_plantuml_input_dir}/"
134139
exit 0
135140
fi
136141
137142
echo "📋 Found PlantUML files:"
138143
echo "$puml_files"
139144
else
140145
echo "⚡ INCREMENTAL MODE - Processing only changed files"
141-
changed_puml_files=$(git diff --name-only HEAD~1 HEAD | grep -E '\.(puml|plantuml)$' | grep '^${{ env.REL_PLANTUML_INPUT_DIR }}/' || true)
146+
changed_puml_files=$(git diff --name-only HEAD~1 HEAD | grep -E '\.(puml|plantuml)$' | grep '^${rel_plantuml_input_dir}/' || true)
142147
143148
if [ -z "$changed_puml_files" ]; then
144149
echo "ℹ️ No PlantUML files changed in this commit"
@@ -163,7 +168,7 @@ jobs:
163168
164169
# process file
165170
base=$(basename "$file" | sed 's/\.[^.]*$//')
166-
prefix_base="${{ env.PLANTUML_PREFIX }}${base}"
171+
prefix_base="${plantuml_prefix}${base}"
167172
echo "📝 Prefix Base name: $prefix_base"
168173
echo "📊 File size: $(ls -lh "$file" | awk '{print $5}')"
169174
@@ -225,25 +230,29 @@ jobs:
225230
run: |
226231
echo "=== 🎯 Generating Draw.io images ==="
227232
228-
rel_input_dir=${{ env.REL_DRAWIO_INPUT_DIR }}
229-
output_dir=${{ env.OUTPUT_DIR }}
233+
# Definitions
234+
rel_drawio_input_dir="src/drawio"
235+
output_dir="$(pwd)/images"
236+
drawio_prefix="diagram_"
237+
238+
echo "📁 Input directory: $rel_drawio_input_dir"
230239
echo "📁 Output directory: $output_dir"
231240
232241
# Determine processing mode
233242
if [ "${{ github.event.inputs.regenerate_all }}" = "true" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
234243
echo "🔄 FULL REGENERATION MODE - Processing all files"
235-
drawio_files=$(find ${{ env.REL_DRAWIO_INPUT_DIR }} -name "*.drawio" -o -name "*.dio" 2>/dev/null)
244+
drawio_files=$(find $rel_drawio_input_dir -name "*.drawio" -o -name "*.dio" 2>/dev/null)
236245
237246
if [ -z "$drawio_files" ]; then
238-
echo "❌ No drawio files found in ${{ env.REL_DRAWIO_INPUT_DIR }}/"
247+
echo "❌ No drawio files found in ${rel_drawio_input_dir}/"
239248
exit 0
240249
fi
241250
242251
echo "📋 Found drawio files:"
243252
echo "$drawio_files"
244253
else
245254
echo "⚡ INCREMENTAL MODE - Processing only changed files"
246-
changed_drawio_files=$(git diff --name-only HEAD~1 HEAD | grep -E '\.(drawio|dio)$' | grep '^${{ env.REL_DRAWIO_INPUT_DIR }}/' || true)
255+
changed_drawio_files=$(git diff --name-only HEAD~1 HEAD | grep -E '\.(drawio|dio)$' | grep '^${rel_drawio_input_dir}/' || true)
247256
248257
if [ -z "$changed_drawio_files" ]; then
249258
echo "ℹ️ No drawio files changed in this commit"
@@ -268,8 +277,8 @@ jobs:
268277
269278
# process file
270279
base=$(basename "$file" | sed 's/\.[^.]*$//')
271-
prefix_base="${{ env.DRAWIO_PREFIX }}${base}"
272-
rel_input_file_path="${rel_input_dir}/$(basename "$file")"
280+
prefix_base="${drawio_prefix}${base}"
281+
rel_input_file_path="${rel_drawio_input_dir}/$(basename "$file")"
273282
echo "📝 Prefix Base name: $prefix_base"
274283
echo "📝 Relative file path: $rel_input_file_path"
275284
echo "📊 File size: $(ls -lh "$file" | awk '{print $5}')"
@@ -300,12 +309,11 @@ jobs:
300309
fi
301310
302311
# find all docker drawio generated *.png images, rename and move them to the /image folder
303-
drawio_dir="${{ env.REL_DRAWIO_INPUT_DIR }}"
304-
png_files=($(find "$(pwd)/$drawio_dir" -name "*.png" -type f | sort))
312+
png_files=($(find "$(pwd)/$rel_drawio_input_dir" -name "*.png" -type f | sort))
305313
306314
# Prüfung auf leeres Array
307315
if [ ${#png_files[@]} -eq 0 ]; then
308-
echo "❌ Keine PNG-Dateien gefunden in '$(pwd)/$drawio_dir'"
316+
echo "❌ Keine PNG-Dateien gefunden in '$(pwd)/$rel_drawio_input_dir'"
309317
exit 1
310318
else
311319
echo "📁 Gefunden: ${#png_files[@]} PNG-Datei(en)"
@@ -349,12 +357,11 @@ jobs:
349357
fi
350358

351359
# find all docker drawio generated *.svg images, rename and move them to the /image folder
352-
drawio_dir="${{ env.REL_DRAWIO_INPUT_DIR }}"
353-
svg_files=($(find "$(pwd)/$drawio_dir" -name "*.svg" -type f | sort))
360+
svg_files=($(find "$(pwd)/$rel_drawio_input_dir" -name "*.svg" -type f | sort))
354361

355362
# Prüfung auf leeres Array
356363
if [ ${#svg_files[@]} -eq 0 ]; then
357-
echo "❌ Keine SVG-Dateien gefunden in '$(pwd)/$drawio_dir'"
364+
echo "❌ Keine SVG-Dateien gefunden in '$(pwd)/$rel_drawio_input_dir'"
358365
exit 1 # oder return 1 in Funktion
359366
else
360367
echo "📁 Gefunden: ${#svg_files[@]} SVG-Datei(en)"
@@ -387,7 +394,11 @@ jobs:
387394
run: |
388395
echo "=== 📊 Final Results ==="
389396
390-
output_dir=${{ env.OUTPUT_DIR }}
397+
# Definitions
398+
plantuml_prefix="uml_"
399+
drawio_prefix="diagram_"
400+
output_dir="$(pwd)/images"
401+
391402
echo "📁 Output directory: $output_dir"
392403
393404
echo "📁 Generated files in $output_dir:"
@@ -398,8 +409,8 @@ jobs:
398409
echo " 📄 Total files: $(ls "${output_dir}/" 2>/dev/null | wc -l)"
399410
echo " 🖼️ PNG files: $(ls "${output_dir}"/*.png 2>/dev/null | wc -l)"
400411
echo " 🎭 SVG files: $(ls "${output_dir}"/*.svg 2>/dev/null | wc -l)"
401-
echo " 🎨 PlantUML files: $(ls "${output_dir}/${{ env.PLANTUML_PREFIX }}"* 2>/dev/null | wc -l)"
402-
echo " 🎯 Draw.io files: $(ls "${output_dir}/${{ env.DRAWIO_PREFIX }}"* 2>/dev/null | wc -l)"
412+
echo " 🎨 PlantUML files: $(ls "${output_dir}/${plantuml_prefix}"* 2>/dev/null | wc -l)"
413+
echo " 🎯 Draw.io files: $(ls "${output_dir}/${drawio_prefix}"* 2>/dev/null | wc -l)"
403414
else
404415
echo " ❌ No images directory found"
405416
fi
@@ -412,7 +423,7 @@ jobs:
412423
run: |
413424
echo "=== 📤 Committing generated images ==="
414425
415-
output_dir=${{ env.OUTPUT_DIR }}
426+
output_dir="$(pwd)/images"
416427
echo "📁 Output directory: $output_dir"
417428
418429
git config --global user.name 'GitHub Actions'

0 commit comments

Comments
 (0)