Appendix A — GitHub Actions

Published

January 26, 2025

A.1 How to build your document with GitHub Actions

Make sure you have setup Pages for your GitHub repo. In the web UI, got to repo > Settings > Pages, and set

Build and deployment: GetHubActions

Then create a .github/workflows/pages.yml file with:

name: "quarto build & gh-pages deploy"

on:
  workflow_dispatch:
  push:
    branches: main

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build-deploy:
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Check out repository
        uses: actions/checkout@v4

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

      - name: Quarto install tinytex
        run: quarto install tinytex

      - name: Install Python and Dependencies
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'
          cache: 'pip'

      - run: pip install jupyter

      - run: pip install -r requirements.txt

      - run: quarto render --to html

      - name: Setup Pages
        uses: actions/configure-pages@v5

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          # Upload this directory
          path: '_site/'

      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

See also: