Build and Deploy Handbook #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy Handbook | |
on: | |
# Trigger the workflow when changes in the handbook/ folder are pushed to the | |
# main branch | |
push: | |
branches: | |
- main | |
paths: | |
- "handbook/**" | |
# Trigger the workflow manually | |
workflow_dispatch: | |
# Provide an input so user can choose to deploy the book, or just build it | |
# (maybe to test the build) | |
inputs: | |
deploy: | |
description: >- | |
Uncheck this box if you only want to build the handbook, and NOT push | |
the HTML files to the gh-pages branch | |
required: false | |
default: true | |
type: boolean | |
jobs: | |
# This job installs dependencies, builds the book, and pushes the generated | |
# html files to the `gh-pages` branch | |
build-and-deploy-book: | |
runs-on: ubuntu-latest | |
# This job needs to commit changes to a branch, which requires write | |
# permissions to the content of the repo | |
# ref: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v2 | |
# Install dependencies | |
- name: Set up Python v3.10 | |
uses: actions/setup-python@v1 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
pip install -r handbook/requirements.txt | |
# Build the book | |
- name: Build the book | |
run: | | |
jupyter-book build handbook | |
# Deploy the book's HTML to gh-pages branch | |
- name: GitHub Pages action | |
# Only run this step if the event was a push, or if the deploy input | |
# is true when running manually | |
if: ${{ github.event_name == 'push' || inputs.deploy == 'true' }} | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: handbook/_build/html |