Motivation

Being an undergraduate, my CV changes frequently as I progress through my degree and new Internship opportunities appear, leaving me with the need to update my CV on LinkedIn and other platforms.

With my interest in programming and computers this task feels repetitive and unnecessary.

This is even more evident when taking into account that LaTeX is easily compiled and that GitLab offers great deployment tools that run, for free, on their servers.

All facts considered, the deployment of my CV to my social networking services was begging to be automated.

Audience

This article is intended for users that wrote their CV (or any other document for that matter) with any flavour of the TeX typesetting (LaTeX, LuaLaTex, XeLaTeX, …). Knowing how to generate a PDF from your TeX file is important in order to follow this article.

Previous knowledge of Git or Docker and GitLab Pages is not necessary, although familiarity with Git commands and related terms will make this article more easy to understand and follow.

I do recommend learning Git as only with knowledge of how to properly use it can the benefits of the automation presented in this article be ensure.

If you haven’t yet, you’ll need to create a GitLab account.

Automate how you deploy your CV

There are two steps that need to be automated in order to keep your published CV up to date with the CV on your repository:

  • Compiling your CV
  • Deploying it

In order to do this, a Docker container hosted on GitLab will be used to run the compiling script that outputs a PDF and then to make it accessible as a GitLab page through a link.

To make the CV always up to date, the previous steps will be integrated as a Continuous Integration (CI) job every time that changes are made to the master branch of the working repository. Gitlab’s new project page

Creating the repository

After creating your GitLab account you can either create a new repository and follow the rest of the article or fork my example and start right away.

You can create a new repository by clicking the New Project button or accessing this link.

Then set your project name, the visibility and click Create Project.

Setting up the repository

Once your project has been created, go to Settings>General on the left. You can also add /edit to the link’s end to access them.

Then go to Visibility, project features, permissions and make sure Pages is set to Everyone.

The other options here can be edited depending on what level of visibility you want for your project, although, for most cases, the visibility options defined once the repository was created are fine.

Creating a CI configuration file

Now that the repository was created and configured we need to add the files related to the TeX documents and configure the CI job. Gitlab’s new file page

For the TeX documents, I recommend creating a directory where the main and related files will be added.

In order to do this go to the option Repository on the left, click the + and select New file. Name the file <DIRECTORY>/main.tex, add the document and commit the changes. Other files can be added to this directory, such as images, fonts and TeX style files. This directory should be used just as any directory in any computer would.

I once again recommend learning git in order to better integrate your workflow with Gitlab so that you can make commits without using the web interface. One simple tool to easily achieve this integration without learning Git to a greater extent is GitKraken.

Having the files in place the only thing missing is configuring the CI job. This is what will ensure that the TeX files will correctly compile to the desired PDF and then will be made public. To do this create a new file with the name .gitlab-ci.yml and the following code as content:

compile_pdf:
  stage: build
  image: texlive/texlive-full:latest
  script:
    - cd ./tex/
    - latexmk -pdflatex=lualatex -pdf main.tex
    - mv main.pdf ../document.pdf
  artifacts:
    paths:
      - document.pdf
pages:
  stage: deploy
  script:
    - mkdir public
    - cp document.pdf public/
  artifacts:
    paths:
      - public
  only:
    - master

This file is divided into two categories: the compilation and the deployment.

First we use the Gitlab’s capability to run a docker image to create a container with the latest version of texlife. Once the container is running, we will change the working directory to ./tex/ where the main file is. Then, to compile the document, there are several options depending on what script is usually used to generate the PDF file. I personally use the latexmk script and, as I’m using LuaLaTeX, the option -pdflatex=lualatex is needed. Other scripts like pdflatex are available as they would in texlife. The generated PDF is then made available as an artifact.

The second part of the configuration file consists of creating a directory with the name public and moving the PDF there. This directory is also made available as an artifact and it only runs if changes are made to the master branch.

Once everything is done and changes are made and committed, Gitlab will automatically run everything in the configuration file taking up to 5 minutes in my experience. The result can be viewed in the repository page which takes the format:

https://<USERNAME>.gitlab.io/<REPOSITORY>/<DOCUMENT>

The link can also be viewed (and even changed) in Settings>Pages.

The link can also be viewed (and even changed) in Settings>Pages.

This link can then be shared in your LinkedIn profile or elsewhere, always pointing to the latest version of the compiled document.

Conclusion

I hope this brief article helped you solve the problem that motivated me to create it: to cease the repetition of a time-consuming, repetitive and easily automated task.

This article is meant to be a small overview of how to achieve the automation of this repetitive task. For more detailed information (and an example) please refer to this repository where give more advice and go into more detail about the options available.