From 6be6eba6ed7df45beed0f845e9faf8059775ee3a Mon Sep 17 00:00:00 2001 From: Marco D'Agostini Date: Thu, 29 Sep 2022 19:20:01 +0200 Subject: [PATCH] Added a Github workflow to build PDFs and expose them as releases --- .github/workflows/build.yaml | 21 +++++++++++++++++++++ build.sh | 35 ++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..64eb97c --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,21 @@ +name: Build + +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install pandoc + run: | + sudo apt-get update + sudo apt-get install pandoc wkhtmltopdf + - name: Build + run: ./build.sh profiles/*.md + - name: Release + uses: softprops/action-gh-release@v1 + # if: startsWith(github.ref, 'refs/tags/') + with: + files: profiles/*.pdf \ No newline at end of file diff --git a/build.sh b/build.sh index 9e02479..23f21bf 100755 --- a/build.sh +++ b/build.sh @@ -1,17 +1,26 @@ #!/usr/bin/env bash -# exit if file does not have '*.md' extension -if [[ "$1" != *.md ]]; then - echo "Error: file must have '*.md' extension." - exit 1 -fi +for inputFile in "$@" +do -# replace '.md' with '.pdf' -filename=${1%.*}.pdf + echo "Parsing \"$inputFile\"" -pandoc <(./parseImport.sh "$1") -o "$filename" --pdf-engine wkhtmltopdf \ - --css styles.css \ - -V margin-top=11mm \ - -V margin-bottom=11mm \ - -V margin-left=11mm \ - -V margin-right=11mm + # exit if file does not have '*.md' extension + if [[ "$inputFile" != *.md ]]; then + echo "Error: file must have '*.md' extension." + exit 1 + fi + + # replace '.md' with '.pdf' + outputFile=${inputFile%.*}.pdf + + echo "Generating \"$outputFile\"" + + pandoc <(./parseImport.sh "$inputFile") -o "$outputFile" --pdf-engine wkhtmltopdf \ + --css styles.css \ + -V margin-top=11mm \ + -V margin-bottom=11mm \ + -V margin-left=11mm \ + -V margin-right=11mm + +done