added auto-generation for svgs

This commit is contained in:
Surferlul 2023-10-13 23:12:11 +02:00
parent 824fba0878
commit 863300c4d8
3 changed files with 32 additions and 8 deletions

View File

@ -4,16 +4,23 @@ inputs:
home-md-file: home-md-file:
description: Markdown file of the page you see when accessing the published site description: Markdown file of the page you see when accessing the published site
required: false required: false
dark-mode:
description: If drawings should be exported in dark mode
required: false
default: 'false'
runs: runs:
using: composite using: composite
steps: steps:
- name: Set up Python 3.12 - name: Start containers
uses: actions/setup-python@v4 run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" up -d --build
with: shell: bash
# Semantic version range syntax or exact version of a Python version - name: Creating SVG files
python-version: '3.12' run: find "${{ github.workspace }}" -type f -name '*.excalidraw' -exec bash "${{ github.action_path }}/to_svg.sh" "{}" ${{ input.dark-mode == 'true' }} ";"
# Optional - x64 or x86 architecture, defaults to x64 shell: bash
architecture: 'x64' - name: Replace excalidraw file references
- run: python ${{ github.action_path }}/main.py "${{ github.workspace }}" "${{ github.workspace }}/${{ inputs.home-md-file}}" run: find "${{ github.workspace }}" -type f -name '*.md' -exec sed -ri 's|(\[\[.*\.excalidraw)(\]\])|\1.csv\2|g' "{}" ";"
shell: bash
- name: Stop containers
run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" down
shell: bash shell: bash

14
docker-compose.yml Normal file
View File

@ -0,0 +1,14 @@
version: "3"
services:
kroki:
image: yuzutech/kroki
depends_on:
- excalidraw
environment:
- KROKI_EXCALIDRAW_HOST=excalidraw
ports:
- "8080:8000"
excalidraw:
image: yuzutech/kroki-excalidraw
expose:
- "8004"

3
to_svg.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
EXCALIDRAW=$(jq '{"type": .type, "version": .version, "source": .source, "elements": .elements, "appState": {"gridSize": null, "exportWithDarkMode": $2}}' "$1")
curl localhost:8080/excalidraw/svg --data-raw "$EXCALIDRAW" > "$1.svg"