From 5ea9b040e2e3b397dd4febab93c12fefbb72a3f7 Mon Sep 17 00:00:00 2001 From: flynn Date: Sun, 11 Oct 2020 20:04:51 +0200 Subject: [PATCH] Add pandoc render --- .gitlab-ci.yml | 27 +++++++++++++++++++++++++++ scripts/md_to_pdf.sh | 8 ++++++++ 2 files changed, 35 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 scripts/md_to_pdf.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..07ec702 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,27 @@ +stages: + install + +image: pandoc:2.10 + +variables: + # Allow git interactions + GIT_AUTHOR_NAME: $GITLAB_USER_NAME + GIT_AUTHOR_EMAIL: $GITLAB_USER_EMAIL + GIT_COMMITTER_NAME: $GITLAB_USER_NAME + GIT_COMMITTER_EMAIL: $GITLAB_USER_EMAIL + +install: + cache: {} + stage: install + script: + # Leave detached git HEAD + - git checkout -B "$CI_COMMIT_REF_NAME" "$CI_COMMIT_SHA" + # Create stageable file and stage it + - cd activiteiten/2020-2021/04_hacktoberfest/ + - sh ../../../scripts/md_to_pdf.sh + - git add -A + # Commit (note the [skip ci] to avoid loop) + - 'git commit -m "chore: render activities [skip ci]"' + + # Push back to repository + - git push --follow-tags --no-verify "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" "HEAD:$CI_COMMIT_REF_NAME" diff --git a/scripts/md_to_pdf.sh b/scripts/md_to_pdf.sh new file mode 100644 index 0000000..6931596 --- /dev/null +++ b/scripts/md_to_pdf.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +echo "Converting to HTML…" + +for file in *.md */*.md + echo " converting $file" + pandoc $file -f markdown -t pdf -o (echo "../$file" | sed '$s/\.md$/.pdf/') -s --data-dir=./ --variable=file:(echo "$file" | sed '$s/\.md$/.pdf/') +end \ No newline at end of file