Compile multiple LaTeX files w/ GitLab CI

Problem

I write down lectures at university in LaTeX (which is really convenient for this purpose), and i want tex files to automatically compile in pdf.

I have couple of .tex files in my repository like this:

.
├── .gitlab-ci.yml
├── lectures
│   ├── math
|   |   ├── differentiation
|   |   |   ├── lecture_math_diff.tex
|   |   |   ├── chapter_1.tex
|   |   |   └── chapter_2.tex
|   |   └── integration
|   |       ├── lecture_math_int.tex
|   |       ├── chapter_1.tex
|   |       └── chapter_2.tex
│   └── physics
|       └── mechanics
|           ├── lecture_physics_mech.tex
|           ├── chapter_1.tex
|           └── chapter_2.tex
└── build_script
    └── build.sh

And as result, i want to have my build artifacts in pdf like this:

├── math
|   ├── lecture_math_diff.pdf
|   └── lecture_math_int.pdf
└── physics
    └── lecture_physics_mech.pdf

What is done

I have a .gitlab-ci.yml:

compile_pdf:
  image: murych/latex-rus-docker
  script:
    - latexmk -pdf *.tex
  artifacts:
    paths:
      - output/

which can’t place any built document in folders


What can be done here?

You’ll probably want to make sure that the latexmk command actually allows you to provide paths with wildcard (*) characters first.

What I’d recommend doing is instead running latexmk -pdf lectures/**/*.tex. directory/**/file.txt means that directory/subdirectory/file.txt as well as directory/subdirectory/subsubdirectory/file.txt would both be captured.