Continuous Integration: Test and Deploy to GitHub Pages#

This chapter shows how to use GitHub Actions to validate and publish your Jupyter Book. It targets HEP trainers building modules with this repository layout.

Start a Git repository in the book directory#

cd YOUR_BOOK_DIRECTORY
git init

This will create .git/ in your book directory.

Warning

Never modify the .git/ directory! Use git commands to manage your repository.

Create a .gitignore file to exclude unnecessary files. For example;

# Content of .gitignore
_build/
__pycache__/

Add everything and make the initial commit:

git add .
git commit -m "Initial commit"

Create a GitHub repository#

Create a new repository on GitHub (do not initialize with README, .gitignore, or license).

Follow the instructions to add your remote and push the initial commit. Basically, something like:

git remote add origin git@github.com:YOUR_USERNAME/YOUR_REPO.git
git branch -M main
git push -u origin main

In Repository Settings / Pages, set “Build and deployment” to “GitHub Actions”.