Skip to content

Commit

Permalink
rework on git action
Browse files Browse the repository at this point in the history
  • Loading branch information
RWTH-MK committed Nov 18, 2024
1 parent 5b7b778 commit 94f9f4d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/conditional_convert_via_pandoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pandoc_texlive_packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%# long list of packages required by Pandoc, s. https://pandoc.org/MANUAL.html#creating-a-pdf

8 changes: 3 additions & 5 deletions pandoc.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down

0 comments on commit 94f9f4d

Please sign in to comment.