I recently switched over this blog to be hosted by GitLab Pages instead of GitHub Pages. Main reason was to implement SSL on a custom domain. You should be seeing this blog at https://www.gshakhn.com if everything went well. Was going to blog about that change, but I mostly just followed this tutorial.
The switch over to GitLab Pages made me play with GitLab CI a bit. I’ve been primarily using GitHub and Travis CI for other personal projects, so I was curious to see how GitLab CI worked. I had mentioned to a coworker that I used LaTeX in Docker to build my resume, and he had joked about auto building it with GitLab CI. Building it is super easy manually and I don’t do it that often, so it’s an obvious candidate for automation. That or I just wanted to play with GitLab CI a bit more.
In the end, I got GitLab CI setup to build my resume and auto-publish it to this blog.
.gitlab-ci.yml file for the resume project:
stages: - deploy - trigger-other-builds pages: stage: deploy image: schickling/latex script: - mkdir public - pdflatex -output-directory public resume.tex artifacts: paths: - public only: - master trigger-gshakhn-com: stage: trigger-other-builds script: - curl -X POST -F token=$GSHAKHN_TOKEN -F ref=master https://gitlab.com/api/v3/projects/$GSHAKHN_PROJECT_ID/trigger/builds
pages job just processes the LaTeX file and generates a PDF. It uses the
schickling/latex image so I don’t have to install LaTeX myself. (It does take a while for GitLab CI to download the image though.) The resulting PDF is then hosted on the project’s GitLab Pages.
trigger-gshakhn-com job uses GitLab Triggers to trigger a build of the blog.
GSHAKHN_PROJECT_ID are Secure Variables I setup in the resume project to reference the Trigger in the blog project. This creates a pipeline so that whenever the resume gets updated, the blog gets updated as well.
.gitlab-ci.yml file for the blog project:
pages: stage: deploy image: jekyll/jekyll:pages script: - wget http://gshakhn.gitlab.io/resume/resume.pdf - bundle exec jekyll build -d public/ artifacts: paths: - public only: - master
It’s pretty much the same as the GitLab tutorial, except:
I use the
jekyll/jekyll:pagesimage. It already has a bunch of gems pre-installed.
wgetto grab the latest version of my resume. Jekyll then packages the file with the rest of the blog.