Skip to content

Commit 1d05f44

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

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

.github/workflows/Pipeline.yml

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

30+
Extract-images:
31+
export-drawio:
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Make script executable
39+
run: chmod +x ./tools/GitLab-CI/export-drawio.sh
40+
41+
- name: Run draw.io export in container
42+
uses: addnab/docker-run-action@v3
43+
with:
44+
image: rlespinasse/drawio-export:latest
45+
options: -v ${{ github.workspace }}:/data
46+
run: |
47+
cd /data
48+
./tools/GitLab-CI/export-drawio.sh test.drawio
49+
50+
- name: Upload PNG artifacts
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: drawio-png
54+
path: |
55+
*.png
56+
3057
PublishTestResults:
3158
uses: pyTooling/Actions/.github/workflows/PublishTestResults.yml@r6
3259
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)