Skip to content

Commit 3ea2cfb

Browse files
committed
test export of sample draw.io image for documentation
1 parent ef8b83e commit 3ea2cfb

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

.github/workflows/Pipeline.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ jobs:
2727
nvc-version: ${{ matrix.version }}
2828
can-fail: ${{ matrix.can-fail }}
2929

30+
Extract-images:
31+
runs-on: ubuntu-24.04
32+
container: jgraph/drawio:latest
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Run export script
38+
run: |
39+
chmod +x ./tools/GitLab-CI/export-drawio.sh
40+
./tools/GitLab-CI/export-drawio.sh "${{ github.event.inputs.drawio_file || 'test.drawio' }}"
41+
env:
42+
DRAWIO_FILE: "${{ github.event.inputs.drawio_file || 'test.drawio' }}"
43+
PATH: "/app:$PATH" # Add drawio CLI path
44+
45+
- name: Upload PNG artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: drawio-exports
49+
path: "*.png"
50+
retention-days: 7
51+
3052
PublishTestResults:
3153
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@r6
3254
needs:

test.drawio

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<mxfile host="Electron" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/28.1.2 Chrome/138.0.7204.243 Electron/37.4.0 Safari/537.36" version="28.1.2">
2+
<diagram name="Seite-1" id="2-pXOjWM6SXTimIP5exn">
3+
<mxGraphModel dx="1426" dy="841" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0" />
6+
<mxCell id="1" parent="0" />
7+
<mxCell id="UljRTUy-i_8bFENZkZiz-1" value="test" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
8+
<mxGeometry x="250" y="250" width="120" height="60" as="geometry" />
9+
</mxCell>
10+
</root>
11+
</mxGraphModel>
12+
</diagram>
13+
</mxfile>

tools/GitLab-CI/export-drawio.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
ANSI_LIGHT_GREEN=$'\x1b[92m'
4+
ANSI_LIGHT_YELLOW=$'\x1b[93m'
5+
ANSI_LIGHT_BLUE=$'\x1b[94m'
6+
ANSI_NOCOLOR=$'\x1b[0m'
7+
8+
for file in "$@"; do
9+
base_name="${file%.*}"
10+
11+
# Count how many pages exist per *.drawio file. Use "diagram" tag as indication. Also extract page names.
12+
mapfile -t names < <(sed -nE 's/.*<diagram.*name="([^"]*).*/\1/p' "$file")
13+
printf "${ANSI_LIGHT_YELLOW}Exporting from '$base_name'${ANSI_NOCOLOR}\n"
14+
15+
# Export each page as an PNG
16+
for i in "${!names[@]}"; do
17+
printf " ${ANSI_LIGHT_BLUE}page '${names[i]}' ...${ANSI_NOCOLOR}\n"
18+
drawio --export --page-index $((i+1)) --crop --border 5 --output "${base_name}_${names[i]}.png" "$file" &
19+
done
20+
done
21+
22+
printf "${ANSI_LIGHT_YELLOW}Waiting for exports to finish ...${ANSI_NOCOLOR}\n"
23+
wait
24+
25+
printf "${ANSI_LIGHT_GREEN}Finished export${ANSI_NOCOLOR}\n"

0 commit comments

Comments
 (0)