Extract individual pages #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: draw.io images | |
on: | |
push: | |
branches: | |
- '**' | |
paths: | |
- '.github/workflows/generate-images-drawio.yml' | |
- 'src/drawio/**' | |
workflow_dispatch: | |
env: | |
DRAWIO_VERSION: 24.2.5 | |
DRAWIO_SRC: src/drawio | |
DRAWIO_OUT: images/drawio | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- 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 xmlstarlet xvfb ./drawio-amd64-${{ env.DRAWIO_VERSION }}.deb | |
- name: Prepare output folder | |
run: | | |
rm -rf "${{ env.DRAWIO_OUT }}" | |
mkdir -p "${{ env.DRAWIO_OUT }}" | |
- name: Export draw.io files as png / svg | |
run: | | |
# draw.io desktop requires a running X server | |
export DISPLAY=:42 | |
Xvfb :42 -nolisten unix & | |
while read -r file; do | |
page=0 | |
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 | |
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 | |
with: | |
add: ${{ env.DRAWIO_OUT }} | |
pull: --rebase --autostash |