tried external svg hosting

This commit is contained in:
Lu Baumann 2023-10-18 13:20:51 +00:00 committed by GitHub
parent a356f47a26
commit 6f9341f728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 3 deletions

View File

@ -5,9 +5,21 @@ inputs:
description: If drawings should be exported in dark mode description: If drawings should be exported in dark mode
required: false required: false
default: 'false' default: 'false'
asset-repo:
description: Repository to store svg assets in
required: ture
asset-repo-branch:
description: The branch to store the svg assets in
required: true
runs: runs:
using: composite using: composite
steps: steps:
- name: Check out logseq-tenset-theme repo
uses: actions/checkout@v4
with:
repository: "${{ inputs.asset-repo }}@${{ inputs.asset-repo-branch }}"
path: svg-repo
- run: mkdir -p svg-repo/svg-assets
- name: Start containers - name: Start containers
run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" up -d --build run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" up -d --build
shell: bash shell: bash
@ -16,8 +28,25 @@ runs:
- name: Creating SVG files - name: Creating SVG files
run: (cd "${{ github.workspace }}" && find . -type f -name '*.excalidraw' -exec bash "${{ github.action_path }}/to_svg.sh" "{}" ${{ inputs.dark-mode == 'true' }} ";") run: (cd "${{ github.workspace }}" && find . -type f -name '*.excalidraw' -exec bash "${{ github.action_path }}/to_svg.sh" "{}" ${{ inputs.dark-mode == 'true' }} ";")
shell: bash shell: bash
- uses: EndBug/add-and-commit@v9 # You can change this to use a specific version.
with:
# The arguments for the `git add` command (see the paragraph below for more info)
# Default: '.'
add: 'svg-assets'
# The name of the user that will be displayed as the author of the commit.
# Default: depends on the default_author input
author_name: logseq-publish-excalidraw-to-svg
# The email of the user that will be displayed as the author of the commit.
# Default: depends on the default_author input
author_email: mail@lu-dev.de
# The local path to the directory where your repository is located. You should use actions/checkout first to set it up.
# Default: '.'
cwd: 'svg-repo'
- name: Replace excalidraw file references - name: Replace excalidraw file references
run: find "${{ github.workspace }}" -type f -name '*.md' -exec sed -ri 's|\[\[(.*\.excalidraw)\]\]|![\1](assets/autogen/\1.svg)|g' "{}" ";" run: find "${{ github.workspace }}" -type f -name '*.md' -exec sed -ri 's|\[\[(.*\.excalidraw)\]\]|![\1](https://raw.githubusercontent.com/${{ inputs.asset-repo }}/${{ inputs.asset-repo-branch }}/svg-assets/\1.svg)|g' "{}" ";"
shell: bash shell: bash
- name: Stop containers - name: Stop containers
run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" down run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" down

View File

@ -3,5 +3,5 @@ EXCALIDRAW="$(jq '{"type": .type, "version": .version, "source": .source, "eleme
ENCODED="$(echo $EXCALIDRAW | python -c "import sys; import base64; import zlib; print(base64.urlsafe_b64encode(zlib.compress(sys.stdin.read().encode('utf-8'), 9)).decode('ascii'))")" ENCODED="$(echo $EXCALIDRAW | python -c "import sys; import base64; import zlib; print(base64.urlsafe_b64encode(zlib.compress(sys.stdin.read().encode('utf-8'), 9)).decode('ascii'))")"
echo ::debug::'$ENCODED' "$ENCODED" echo ::debug::'$ENCODED' "$ENCODED"
docker ps docker ps
mkdir -p "assets/autogen/$(dirname $1)" mkdir -p "svg-repo/svg-assets/$(dirname $1)"
curl "localhost:8080/excalidraw/svg/$ENCODED" > "assets/autogen/$1.svg" curl "localhost:8080/excalidraw/svg/$ENCODED" > "svg-repo/svg-assets/$1.svg"