diff --git a/.github/workflows/generate-images-drawio.yml b/.github/workflows/generate-images-drawio.yml index 48025f74..8b347929 100644 --- a/.github/workflows/generate-images-drawio.yml +++ b/.github/workflows/generate-images-drawio.yml @@ -23,11 +23,11 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - - name: Set up Xvfb & draw.io desktop + - name: Set up xmlstarlet, Xvfb & draw.io desktop run: | wget -q https://github.com/jgraph/drawio-desktop/releases/download/v${{ env.DRAWIO_VERSION }}/drawio-amd64-${{ env.DRAWIO_VERSION }}.deb sudo apt-get update - sudo apt-get install --yes --no-install-recommends xvfb ./drawio-amd64-${{ env.DRAWIO_VERSION }}.deb + sudo apt-get install --yes --no-install-recommends xmlstarlet xvfb ./drawio-amd64-${{ env.DRAWIO_VERSION }}.deb - name: Prepare output folder run: | @@ -40,15 +40,22 @@ jobs: export DISPLAY=:42 Xvfb :42 -nolisten unix & - for ext in png svg; do - # The chromium args need to be specified last because of whatever - drawio --export --recursive --format $ext "${{ env.DRAWIO_SRC }}" --no-sandbox --disable-gpu --disable-dev-shm-usage + while read -r file; do + page=0 - rsync -v --recursive --include="*.$ext" --filter="-! */" "${{ env.DRAWIO_SRC }}"/* "${{ env.DRAWIO_OUT }}" + while read -r pagename; do + for ext in png svg; do + # The chromium args need to be specified last because of whatever + drawio --export -p $page -o "${file/.drawio/-$pagename}.$ext" "$file" --no-sandbox --disable-gpu --disable-dev-shm-usage + done - # Nuke the exported files so that draw.io desktop doesn't attempt to use them as input files on the next loop pass - find "${{ env.DRAWIO_SRC }}" -name "*.$ext" -exec rm -v "{}" \; - done + page=$((page + 1)) + + # For whatever reason xmlstarlet doesn't end its output with a newline so we append one with echo to not lose the last line + done < <(xml sel -t -v "//diagram/@name" "$file"; echo) + done < <(find "${{ env.DRAWIO_SRC }}" -name "*.drawio") + + rsync -v --recursive --include="*.png" --include="*.svg" --filter="-! */" "${{ env.DRAWIO_SRC }}"/* "${{ env.DRAWIO_OUT }}" - name: Add & Commit uses: EndBug/add-and-commit@v9