From 94f9f4d00d89cfa7fb33ed7a29fd8ba95dc0b1dd Mon Sep 17 00:00:00 2001 From: RWTH-MK Date: Tue, 19 Nov 2024 00:46:07 +0100 Subject: [PATCH] rework on git action --- .../conditional_convert_via_pandoc.yml | 24 ++++++++++--------- .github/workflows/pandoc_texlive_packages.txt | 2 ++ pandoc.sh | 8 +++---- 3 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/pandoc_texlive_packages.txt diff --git a/.github/workflows/conditional_convert_via_pandoc.yml b/.github/workflows/conditional_convert_via_pandoc.yml index 5ab4ce9..f03c742 100644 --- a/.github/workflows/conditional_convert_via_pandoc.yml +++ b/.github/workflows/conditional_convert_via_pandoc.yml @@ -3,10 +3,11 @@ name: conditional_convert_via_pandoc # A script to check for changed and added .md files in content/ and convert those with pandoc (except for _index.md) # # Thanks to Gérald Barré aka. meziantou for the basic template of the condition check +# Thanks as well as to Azeem, mb21, Benjamin W., KamilCuk & Teemu Risikko over at stackoverlow.com # Written by Marcel Kaiser # # published: 2024-10-29 -# last edit: 2024-11-16 +# last edit: 2024-11-18 # on: push: @@ -38,11 +39,9 @@ jobs: echo "bool_files_changed=$HasDiff" >> $env:GITHUB_OUTPUT echo "list_changed_files=$FilesDiff" >> $env:GITHUB_OUTPUT - # Run the job only with 'bool_files_changed' equals 'True' + # Run the job only with 'bool_files_changed' equals 'true' conditional_pandoc: runs-on: 'ubuntu-22.04' - container: - image: pandoc/latex:3.5 needs: [ condition_check_files ] if: needs.condition_check_files.outputs.bool_files_changed == 'true' env: @@ -51,14 +50,17 @@ jobs: - uses: actions/checkout@v4 # In order to find the script pandoc.sh with: fetch-depth: 2 - - name: Run Pandoc in Docker - # This is a one-liner. It gets a Docker Image of pandoc/latex:3.5 working directly in the workspace (because - # $list_changed_files contains relative paths) and executes the script. + - uses: pandoc/actions/setup@v1 + with: + version: 3.5 + - uses: teatimeguest/setup-texlive-action@v3 # To convert to pdf (from latex) + with: + package-file: | + .github/workflows/pandoc_texlive_packages.tex + - name: Run Pandoc run: | - if ! dpkg-query -W -f='${Status}' parallel | grep "ok installed"; - then apt install parallel; - fi - ./pandoc.sh ${{ env.list_changed_files }} + echo "$list_changed_files" + bash ./pandoc.sh "$list_changed_files" - name: Commit files # transfer the new files into the repository run: | git config --local user.name "GH_Action_Bot" diff --git a/.github/workflows/pandoc_texlive_packages.txt b/.github/workflows/pandoc_texlive_packages.txt new file mode 100644 index 0000000..86cf6c9 --- /dev/null +++ b/.github/workflows/pandoc_texlive_packages.txt @@ -0,0 +1,2 @@ +%# long list of packages required by Pandoc, s. https://pandoc.org/MANUAL.html#creating-a-pdf + diff --git a/pandoc.sh b/pandoc.sh index 03238a4..747ee46 100755 --- a/pandoc.sh +++ b/pandoc.sh @@ -1,10 +1,8 @@ -#!/bin/sh -# List types which will only use --standalone. You can easily add more extensions if you're fine with this setting +#!/bin/bash +# You can add more extensions if you're fine with --standalone only Only_Standalone_Output_Types="latex pdf html docx odt" -# Use GNU Parallel to work each file on its own cpu core. In case it isn't installed: - # Pandoc creates an AST (Abstract Syntax Tree); reuse this by saving/reading from .ast -# You can easily add individual conversion rules by using pandoc after the 'done' part. Keep in mind to finish all non-comment lines with backslash +# You can add individual pandoc conversions by calling them after the 'done' part. Keep in mind to finish all lines with backslash parallel --jobs 0 \ pandoc --from markdown --to native './{}' -o './{.}.ast' ';'\ for i in "$Only_Standalone_Output_Types"';' do \