Add CI/CD workflows for Jupyter notebook linting, testing, and per-branch GitHub Pages deployment #4
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 automated workflows to lint, test, and execute notebooks on CI, plus deploy them as HTML to GitHub Pages with per-branch isolation.
Changes
CI Workflow (
.github/workflows/ci.yml)blank.ymlwith comprehensive CI checksflake8linting,pytesttests, and validates all notebooks execute without errorsmainbranchDeployment Workflow (
.github/workflows/deploy-notebooks-pages.yml)scripts/build_notebooks.pygh-pagesbranch under/<branch-name>/pathsSupporting Infrastructure
scripts/build_notebooks.py: Executes notebooks with 10min timeout, generates HTML with error pages for failures, HTML-escapes error outputrequirements.txt: Core dependencies (jupyter, nbconvert, flake8, pytest).flake8: Excludes notebooks and build artifacts from lintingtests/test_build_notebooks.py: Basic validation testsCONTRIBUTING.md: Developer documentation for CI/CD workflowsExample Usage
Deployed notebooks will be available at:
https://<org>.github.io/<repo>/<branch>/for branch-specific buildshttps://<org>.github.io/<repo>/for branch indexOriginal 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 provided):
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
")- {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 ...
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.