Skip to content

05 CI & CD with GitHub Actions & GitHub Pages

Neha Moopen edited this page Aug 5, 2021 · 3 revisions

CI = Continuous Integration. This is the practice of automating the integration of (code) changes from multiple contributors into a single (software) project.

CD = Continuous Deployment. This is the practice of automatically launching the project to end-users via, for example, a website.

Continous Integration with GitHub Actions

GitHub Actions allows for automation of software workflows. In our case, we use GitHub Actions to automate building and deploying the Handbook.

This means the Handbook can 'live' on GitHub instead of someone's local computer folder. Contributors don't have to manually build the book on their computers with R Studio, the book is (re)built automatically on GitHub when changes are made/approved.

Continuous Deployment with GitHub Pages

GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, and publishes a website. The website is hosted on GitHub's github.io domain and the URL reflects the user/organization and repository. The Handbook's URL is, therefore: https://utrechtuniversity.github.io/dataprivacyhandbook

Note: Technically, GitHub Actions takes care of the Continuous Deployment via GitHub Pages as well - but it's easier to document the process by splitting CI & CD into sections.

The Workflow

The following guide provided the basis for setting up our CI/CD workflow: https://medium.com/@delucmat/how-to-publish-bookdown-projects-with-github-actions-on-github-pages-6e6aecc7331e

The workflow is contained within the deploy_bookdown.yml file which can found in dataprivacyhandbook -> .github -> workflows (link)

Usage

  • Steps from III Create a GitHub Action workflow were followed because the Handbook was already on GitHub.

  • The GH_PAT & EMAIL GitHub secrets were set up by Neha Moopen, and therefore linked to her GitHub account.

  • The default branch on the Handbook repository is main not master. This was adjusted in the deploy_bookdown.yml workflow.

  • The output directory was changed to docs instead of _book in the initial bookdown setup. This was also adjusted in the deploy_bookdown.yml workflow where the artifact's name, path, and BUILD_DIR have to be specified.

  • The guide utilizes a GitHub Action workflow called GitHub Pages Deploy, but the version/release is outdated.

The guide shows: uses: Cecilapp/GitHub-Pages-deploy@master

Whereas we have updated to: uses: Cecilapp/GitHub-Pages-deploy@v2