Using pandoc in CI to convert all markdown files in repo to PDF


i’d like to convert all of my markdown files in my repository to PDF and upload them as artifacts using CI.
I wanted to use pandoc to convert the md’s to PDF. Locally it works fine, but somehow the CI process using docker does not work. I’d like to prefer using docker, as this is a more portable solution.

Here is my minimal .gitlab-ci.yml

`image: pandoc/core:latest


    - apt-get update && apt-get install -y texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra
    - find . -name '*.md' -exec pandoc --pdf-engine=xelatex '{}' --output '{}'.pdf \;
      - "*.pdf"

The jobs returns fails with the following error:

Using docker image sha256:85f93f2efdc53ef7effed2f7ba1f3e5c095bdab457e9919934539950083ab816 for pandoc/core:latest with digest pandoc/core@sha256:222badaf55d35aa19a54294721b2669a55737e8a96e78f038b89c2b70bccd13f ...
[WARNING] Could not deduce format from file extension 
  Defaulting to markdown
pandoc: sh: openBinaryFile: does not exist (No such file or directory)
Cleaning up project directory and file based variables 00:04
ERROR: Job failed: exit code 1

After fiddeling arond a bit on my local machine, could it be that the pandoc container does not contain the find binary?
If i had a single markdown file, i guess i could pass it to the container, and it would be converted. But this would mean, that i had to run a script “bare metal” and issue the docker host to run the container manuall (which i think is not a very elegant solution).
The alternative would be to build a pandoc container, that has a somewhat minimal linux environment, but actually i wouldn’t want to do that, just to convert my files to PDF.

Anyone did something already?

Just found this link:

1 Like