Automating Jekyll site updates with GitLab CI Schedules

1 minute read

One of the earliest posts I made on this site described the process I used to automate daily updates using a Raspberry Pi server running Raspbian. With my recent move of the site to GitLab Pages, I was able to automate daily site updates without the need of an external server. This was made possible through the magic of the GitLab CI (Continuous Integration) Scheduling.

For those not familiar with GitLab Pages, it uses a CI configuration file (.gitlab-ci.yml) to define how the website is built from the GitLab project source files. See my previous post which covers this process in detail. To summarize, each time the site source files are updated, GitLab starts a CI Pipeline and rebuilds the website following the directions in the CI configuration file. As I learned more about the GitLab CI process, I discovered CI Pipelines can be scheduled to run automatically.

This site uses the Jekyll sample filter to select a random quote for the main page Message of the Day, which requires only a simple site rebuild to update the message. For the full details on this process, see my original post here. Using the GitLab CI Scheduler, I could schedule a rebuild at midnight each day to update the site, which would eliminate all external server dependencies.

To add a Pipeline Schedule to a project in GitLab, open the project and select CI / CD, Schedules. All active and inactive schedules will appear on this page as shown below.

To add a new schedule, click on the New Schedule button and fill in the details as necessary, such as the Description, Interval, Timezone and Target Branch. There are several default intervals available, and custom intervals can be entered using standard Unix cron format. This schedule shown below will force a rebuild of the project each day at 12:01am, no external server needed.

There are many more advanced options available through GitLab CI, for example, variables can be included in the schedule, which can be referenced in the CI configuration file allowing further customizations of the build process. For more information on this process, refer to the GitLab Pipeline schedules documentation. I’m already looking into other ways to customize this site using variables in the GitLab CI build process. Watch for future updates here.

To contact me, please use the Contact page, or message me on Twitter. Thanks for reading.