logseq-publish-excalidraw-t.../action.yml
2023-10-18 15:58:52 +02:00

50 lines
1.9 KiB
YAML

name: Logseq Excalidraw to SVG
description: A preprocessor for logseq-spa. Converts excalidraw to svg references
inputs:
dark-mode:
description: If drawings should be exported in dark mode
required: false
default: 'false'
asset-repo:
description: Repository to store svg assets in
required: true
asset-repo-branch:
description: The branch to store the svg assets in
required: true
asset-repo-token:
descriptioin: Github token to access the asset repo when pulling and pushing
required: true
runs:
using: composite
steps:
- name: Check out logseq-tenset-theme repo
uses: actions/checkout@v4
with:
repository: "${{ inputs.asset-repo }}"
ref: "${{ inputs.asset-repo-branch }}"
path: svg-repo
token: "${{ inputs.asset-repo-token }}"
- run: mkdir -p svg-repo/svg-assets
shell: bash
- name: Start containers
run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" up -d --build
shell: bash
- run: bash "${{ github.action_path }}/wait_for_kroki.sh"
shell: bash
- 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' }} ";")
shell: bash
- uses: EndBug/add-and-commit@v9
with:
add: 'svg-assets'
author_name: logseq-publish-excalidraw-to-svg
author_email: mail@lu-dev.de
cwd: 'svg-repo'
- name: Replace excalidraw file references
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
- name: Stop containers
run: docker-compose -f "${{ github.action_path }}/docker-compose.yml" down
shell: bash