Skip to content
Latchkey

publish-book workflow (mwouts/itables)

The publish-book workflow from mwouts/itables, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: mwouts/itables.github/workflows/publish-book.ymlLicense MITView source

What it does

This is the publish-book workflow from the mwouts/itables repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
  # Only run this when the main branch changes
on:
  push:
    branches:
    - main
    # If your git repository has the Jupyter Book within some-subfolder next to
    # unrelated files, you can make this run only if a file within that specific
    # folder has been modified.
    #
    # paths:
    # - docs/**

# This job installs dependencies, builds the book, and pushes it to `gh-pages`
jobs:
  deploy-book:
    # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
    permissions:
      pages: write      # to deploy to Pages
      id-token: write   # to verify the deployment originates from an appropriate source

    # Deploy to the github-pages environment
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}

    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6

    - name: Set up Node
      uses: actions/setup-node@v6

    - name: Set up Python 3.11
      uses: actions/setup-python@v6
      with:
        python-version: 3.11

    - name: Install dependencies
      run: |
        pip install 'jupyter-book<2' sphinxext-rediraffe
        pip install matplotlib  # Pandas style
        pip install .[all]

    - name: Create a kernel
      run: |
        pip install ipykernel
        python -m ipykernel install --name itables --user

    - name: Install Quarto
      uses: quarto-dev/quarto-actions/setup@v2

    - name: Render the quarto examples
      run: |
        for qmd_file in `ls docs/quarto/*.qmd`; do quarto render ${qmd_file}; done

    # Build the book
    - name: Build the book
      run: |
        jupyter-book build docs

    # Upload the book's HTML as an artifact
    - name: Upload artifact
      uses: actions/upload-pages-artifact@v5
      with:
        path: "docs/_build/html"

    # Deploy the book's HTML to GitHub Pages
    - name: Deploy to GitHub Pages
      id: deployment
      uses: actions/deploy-pages@v5

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

  # Only run this when the main branch changes
on:
  push:
    branches:
    - main
    # If your git repository has the Jupyter Book within some-subfolder next to
    # unrelated files, you can make this run only if a file within that specific
    # folder has been modified.
    #
    # paths:
    # - docs/**
 
# This job installs dependencies, builds the book, and pushes it to `gh-pages`
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  deploy-book:
    timeout-minutes: 30
    # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
    permissions:
      pages: write      # to deploy to Pages
      id-token: write   # to verify the deployment originates from an appropriate source
 
    # Deploy to the github-pages environment
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
 
    runs-on: latchkey-small
    steps:
    - uses: actions/checkout@v6
 
    - name: Set up Node
      uses: actions/setup-node@v6
      with:
        cache: 'npm'
 
    - name: Set up Python 3.11
      uses: actions/setup-python@v6
      with:
        python-version: 3.11
 
    - name: Install dependencies
      run: |
        pip install 'jupyter-book<2' sphinxext-rediraffe
        pip install matplotlib  # Pandas style
        pip install .[all]
 
    - name: Create a kernel
      run: |
        pip install ipykernel
        python -m ipykernel install --name itables --user
 
    - name: Install Quarto
      uses: quarto-dev/quarto-actions/setup@v2
 
    - name: Render the quarto examples
      run: |
        for qmd_file in `ls docs/quarto/*.qmd`; do quarto render ${qmd_file}; done
 
    # Build the book
    - name: Build the book
      run: |
        jupyter-book build docs
 
    # Upload the book's HTML as an artifact
    - name: Upload artifact
      uses: actions/upload-pages-artifact@v5
      with:
        path: "docs/_build/html"
 
    # Deploy the book's HTML to GitHub Pages
    - name: Deploy to GitHub Pages
      id: deployment
      uses: actions/deploy-pages@v5
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow