Add CI/CD workflows for notebook testing, linting, and per-branch GitHub Pages deployment #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds GitHub Actions workflows to automate testing, linting, and publishing of Jupyter notebooks as static HTML sites with per-branch isolation on GitHub Pages.
Workflows
.github/workflows/ci.yml- Runs on main branch push/PR:contents: read).github/workflows/deploy-notebooks-pages.yml- Runs on all branch pushes:scripts/build_notebooks.pygh-pagesbranch under<branch-name>/subdirectorygh-pagesbranch if missingScript
scripts/build_notebooks.pyrecursively finds and processes notebooks:Creates
index.htmlshowing build status (✓/✗) for each notebook.Dependencies
requirements.txtspecifies:jupyter,nbconvert,nbformat,pytest,flake8.gitignoreexcludes build artifacts (site/,gh-pages/), Python cache, and temporary files.Original prompt
Add CI, notebook build and deployment workflows, supporting scripts, tooling, and documentation to enable building, testing, linting, and publishing Jupyter notebooks as branch-specific HTML pages on GitHub Pages.
Files to add (exact contents):
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
on:
push:
branches:
name: Build and deploy notebooks to GitHub Pages (per-branch)
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write # needed to push gh-pages
steps:
- name: Checkout repository (current branch)
uses: actions/checkout@v4
with:
fetch-depth: 0
import os, json
root='gh-pages'
items = sorted([d for d in os.listdir(root) if os.path.isdir(os.path.join(root,d))])
index_path = os.path.join(root, 'index.html')
with open(index_path, 'w') as f:
f.write("<title>Branches</title>")
f.write("
Published branches
")- <a href="./{d}/">{d}
')
")for d in items:
f.write(f'
f.write("
PY
#!/usr/bin/env python3
"""
Execute all notebooks in the repository (recursive) and export them to HTML into an output folder.
Usage:
python scripts...
This pull request was created as a result of the following prompt from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.