From 863300c4d819795a7476e6a2ee14fb7d7d85374e Mon Sep 17 00:00:00 2001 From: Surferlul Date: Fri, 13 Oct 2023 23:12:11 +0200 Subject: [PATCH] added auto-generation for svgs --- action.yml | 23 +++++++++++++++-------- docker-compose.yml | 14 ++++++++++++++ to_svg.sh | 3 +++ 3 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 docker-compose.yml create mode 100755 to_svg.sh diff --git a/action.yml b/action.yml index 88402d8..d819787 100644 --- a/action.yml +++ b/action.yml @@ -4,16 +4,23 @@ inputs: home-md-file: description: Markdown file of the page you see when accessing the published site required: false + dark-mode: + description: If drawings should be exported in dark mode + required: false + default: 'false' runs: using: composite steps: - - name: Set up Python 3.12 - uses: actions/setup-python@v4 - with: - # Semantic version range syntax or exact version of a Python version - python-version: '3.12' - # Optional - x64 or x86 architecture, defaults to x64 - architecture: 'x64' - - run: python ${{ github.action_path }}/main.py "${{ github.workspace }}" "${{ github.workspace }}/${{ inputs.home-md-file}}" + - name: Start containers + run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" up -d --build + shell: bash + - name: Creating SVG files + run: find "${{ github.workspace }}" -type f -name '*.excalidraw' -exec bash "${{ github.action_path }}/to_svg.sh" "{}" ${{ input.dark-mode == 'true' }} ";" + shell: bash + - name: Replace excalidraw file references + 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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..10593d5 --- /dev/null +++ b/docker-compose.yml @@ -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" \ No newline at end of file diff --git a/to_svg.sh b/to_svg.sh new file mode 100755 index 0000000..787b3f4 --- /dev/null +++ b/to_svg.sh @@ -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"