CI/CD for LaTeX Resumes

Matthew Lam · March 25, 2023

About

Have a LaTeX resume? Lets compile it and store it in the cloud with Github Actions! By the end of this, you will have a CI/CD pipeline for your resume, so that every commit to your LaTeX resume will result in an automatic recompilation, uploaded to OCI Object Storage, and available at a URL to be shared just like my own resume.

Step 1. Setup Github Repository

First things first, you need a Github repository with your LaTeX resume. The resume repository should have your .tex file at root.

$ git ls-tree master --name-only
.github
.gitignore
README.md
res.cls
resume.tex

In this example, the resume can be compiled into a pdf with the command

$ pdflatex resume.tex

Step 2. Setup OCI Tenancy

Next we need an Oracle Cloud Infrastructure tenancy which will contain the object storage bucket which will contain the resulting resume file. While I am using OCI, it could easily be any other S3 style object storage.

If you don’t have one already, create an OCI Free Tier account.

The first thing we need to setup is our OCI User SDK/CLI Configuration file. To do this first create or upload an API Signing Key. I would reccomend having OCI Generate the API Signing Key, as we will only be using this key for our Github action. Be sure to save the Private Key, Public Key, Tenancy OCID, User OCID, and Region from the generated Config file. It should look something like this.

[DEFAULT]
user=ocid1.user.oc1..<your user ocid>
fingerprint=<your fingerprint>
tenancy=ocid1.tenancy.oc1..<your tenancy ocid>
region=us-phoenix-1 # Could be any region
key_file=<path to your private keyfile> # TODO

Next create a object storage bucket in the Object Storage Sevice. If you aren’t sure where the service is, you can search “Buckets” in the console search. We want to default the bucket to Private, as we will later be creating a PAR to access later.

Step 3. Setup Github Actions

Now we will setup a github actions config to do the following.

  1. Checkout the repository.
  2. Compile the LaTeX resume as a pdf.
  3. Upload the pdf to the bucket created above.

Create a YAML file in the repo in the path called

.github/workflows/build.yml

A basic github action that will run when you git push, but ignore changes to the README.md looks like

name: Build LaTeX document
on: 
  push:
    paths-ignore:
      - '**/README.md'
jobs:
  build_latex:
    runs-on: ubuntu-latest
    steps:

Next we will add the step to Checkout the repo using actions/checkout.

    steps:
      - name: Set up Git repository
        uses: actions/checkout@v1

Next install the utilities to create the pdf from the .tex

    - name: Install deps
        run: |
          sudo apt-get update && sudo apt-get -y install poppler-utils

Compile latex to pdf using Github Action for LaTeX

    - name: Compile LaTeX document
        uses: xu-cheng/latex-action@v2
        with:
          root_file: resume.tex

Finally, we need to upload to resulting pdf to our OCI Object Storage bucket using Run an Oracle Cloud Infrastructure (OCI) CLI command. As a prerequisite to using this action, we need to have some ENV variables set. The values will be injected from Github Actions Secrets. Create a Secret for each with values from the OCI config you created above.

OCI_CLI_USER
OCI_CLI_TENANCY
OCI_CLI_FINGERPRINT
OCI_CLI_KEY_CONTENT
OCI_CLI_REGION

Once you have created Github Actions Secrets for each of these, in the yaml set the enviroment variables for the job.

jobs:
  build_latex:
    runs-on: ubuntu-latest
    env:
      OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
      OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
      OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
      OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
      OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
    steps:

The last step is to put the pdf into the bucket using the oci cli with the arguments

  • –bucket-name - Name of the bucket you created above.
  • –file - resume.pdf - Name of the pdf file generated by the previous action.
  • –name - File name of the object in the bucket. I would reccomend putting your name in the filename.
  • –content-type - application/pdf so that browsers will know to treat the content as a pdf instead of the default ‘application/octet-stream’
  • –force - If the object name already exists, overwrite the existing object without a confirmation prompt.
    - name: Run an Oracle Cloud Infrastructure (OCI) CLI command
        uses: oracle-actions/run-oci-cli-command@v1.1.1
        with:
          command: os object put --bucket-name YOURBUCKET --file resume.pdf --name YOURNAME.pdf --content-type application/pdf --force

You can view my full build.yaml here

Step 4. Setup PAR to File

Now that your bucket contains your resume.pdf, in the console or cli we will want to create a Pre-authenticated request to provide a way to let users access our pdf object without having their own credentials.

Create a PAR with the Permit object reads access type to the pdf object. You can make the expiration like 10 or more years into the future. When you create it, there will be a secret URL created, make sure you copy this down as it will be your public URL to the pdf.

For example my URL to read my Resume is https://objectstorage.us-phoenix-1.oraclecloud.com/p/9zSOm_Gk-v0hyUJWbfeq2iiBcuZ4iZE4xR71u8UhhQCEcJ6E8cZJFHppxM7Ao9aI/n/axlhfpsumuyq/b/mbucket/o/MatthewLamResume.pdf

Now, everytime you make a change to your resume this Github Action will compile and overwrite the pdf in object storage with the latest version and it will be available to share with the PAR.

Twitter, Facebook