Manually building and deploying your LaTeX projects can be a very tedious process, you could store it in dropbox and manually build it to always have the latest version available but we can do it better. Even a simple LaTeX project can benefit from using a continuous integration pipeline, in this tutorial we are going to use Gitlab CI. Using Gitlab CI we can automatically build our project and deploy it to Gitlab pages to always has the latest version. In this example we’re going to use a Lorem Ipsum template, for the full source code take a look to the repo.

Assuming you already has a gitlab repo of the project lets set up Gitlab CI by creating the .gitlab-ci.yml file:

pages:
  image: aergus/latex
  script:
  - 'echo "Compiling..." '
  - pdflatex -interaction=nonstopmode -halt-on-error lorem.tex
  - 'echo "Deploying..." '
  - mkdir public
  - mv lorem.pdf public/
  artifacts:
    paths:
    - public
  only:
   - master

In this example we are using pdflatex to build the lorem.tex file and produce a pdf, -interaction=nonstopmode disables the interactive options and makes the latex compiler run without user input, -halt-on-error makes pdflatex returns an error code when an error in the build is encountered, Also if the build fails gitlab sends you and email reporting the errors so if you accidentally break something you will know as soon as you open your inbox. Finally the last step is to copy the resulting pdf to the public/ folder, here we copy the files that are going to be serve by gitlab pages.

Gitlab pages works almost like github pages, so your files will be available in https://username.gitlab.io/repo-name/file URL, so for our Lorem Ipsum example the URL would be:

https://wolfgang000.gitlab.io/latex-lorem/lorem.pdf

You can even use a custom domain or add branches with multiple versions of the project. In particular I find it very useful to keep my resume always update.