Skip to content

Commit

Permalink
Extract individual pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Johennes committed May 15, 2024
1 parent 68b73fc commit e2d322d
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/generate-images-drawio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down

0 comments on commit e2d322d

Please sign in to comment.