GitHub action to convert LaTeX document in PDF file with LuaTeX
.
output_dir
: use it to get the PDF file at a specific location at the end of the compilation.main_latex_file
: main latex file to convert (ex:main.tex
).ctan_packages
: Extra package from CTAN to install. List of packages available here. Each package must be separated by a space (ex: "moderncv xargs")."toc
: boolean to add ToC or not. Defaultfalse
. It will compile the document twice to generate the ToC withLuaTeX
.
You can refer to the example attached in this repository.
In the example below we compile the document in PDF and upload as an artefact of the pipeline:
name: LateX to PDF
on:
push:
branches:
- master
- develop
tags:
- '*'
pull_request:
branches: [ master ]
jobs:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v2
- name: latex2pdf
id: compile-latex-document
uses: thomas-chauvet/[email protected]
with:
output_dir: output
main_latex_file: test.tex
ctan_packages: amsmath amsfonts lua-uni-algos
- name: Upload PDF to the workflow tab
id: upload-workflow-tab
uses: actions/upload-artifact@v2
with:
name: output
path: output/test.pdf
You can find a more complete example in my CV repository with everything to release the PDF document.
Build docker image:
docker build -t latex2pdf .
Run the example:
docker run \
-e OUTPUT_DIR="output" \
-e MAIN_LATEX_FILE="test.tex" \
-e CTAN_PACKAGES="amssymb latexsym amsmath" \
-v "${PWD}/resources/test.tex":"/test.tex" \
-v "${PWD}/output":"/output" \
latex2pdf
The Docker
images used to compile the document is based on Ubuntu
and the excellent work of @Yihui for TinyTeX. It allows the image to stay relatively small and use only what is needed.