Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# This workflow publishes the reviewed source on master to GitHub Pages.
# It is deliberately manual: merging a pull request does not publish anything.
# Run it from GitHub's Actions tab only when the current master is ready to go
# live.
name: Deploy website

# workflow_dispatch creates the "Run workflow" button in the GitHub interface
# and also permits the equivalent "gh workflow run" command.
on:
workflow_dispatch:

# Start with no token permissions. Each job receives only what it needs below.
permissions: {}

# Never let two deployments modify the Pages site simultaneously. An in-flight
# release is allowed to finish rather than being cancelled by a later click.
concurrency:
group: github-pages
cancel-in-progress: false

jobs:
build:
name: Build Pages artifact
runs-on: ubuntu-latest
timeout-minutes: 20

# Building needs source access and read access to the existing Pages
# configuration. It cannot change repository content or deploy a site.
permissions:
contents: read
pages: read

env:
# Jupyter Book 2 uses a managed Node.js runtime for its web theme.
# The runner is non-interactive, so managed installation is permitted
# explicitly.
JB_ALLOW_NODEENV: "1"

steps:
# The Actions interface can offer other refs in its branch selector.
# Refuse them explicitly: only reviewed source on master may be deployed.
- name: Confirm the trusted deployment branch
shell: bash
run: |
if [[ "$GITHUB_REF" != "refs/heads/master" ]]; then
echo "Refusing to deploy $GITHUB_REF; select master."
exit 1
fi

# Download the exact master commit selected for this workflow run.
# Actions are pinned to immutable commit hashes; comments retain their
# readable release versions for future updates.
- name: Check out the website source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

# Read the site's Pages URL and base path. For this user site the base path
# is normally empty/root, but deriving it avoids hard-coding that detail.
- name: Read the GitHub Pages configuration
id: pages
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0

# Install the same uv release used by local validation. The cache speeds
# dependency downloads; uv.lock still fixes the Python package versions.
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
version: "0.12.18"
enable-cache: true

# uv reads .python-version, currently Python 3.12.
- name: Install the pinned Python version
run: uv python install

# --locked fails if pyproject.toml and uv.lock disagree rather than
# silently resolving a different environment during deployment.
- name: Synchronize the locked environment
run: uv sync --locked

# Build exactly as validation does. BASE_URL makes generated links correct
# if the Pages location ever changes from the root URL.
- name: Build the production website
env:
BASE_URL: ${{ steps.pages.outputs.base_path || '/' }}
run: uv run --locked jupyter book build --html --strict

# This special Pages artifact is temporary deployment input. It is not
# committed to gh-pages and contains only the generated static website.
- name: Package the generated website for Pages
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: _build/html

deploy:
name: Deploy to GitHub Pages
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10

# Only this job can create a Pages deployment. The identity token proves to
# GitHub that the request came from this specific trusted workflow job.
permissions:
pages: write
id-token: write

# GitHub records the deployment and its URL in the protected Pages
# environment. Environment rules can later add another approval gate.
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
# Deploy the github-pages artifact produced by the successful build job.
# The action reports the resulting public URL as page_url above.
- name: Publish the Pages artifact
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
15 changes: 13 additions & 2 deletions PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ Setup, validation, and preview commands are documented in `README.md`.
- Delete the local and remote `website-modernization` branches only after the
merged baseline has been rechecked.

**Progress:** `master` is protected by required pull requests, resolved
conversations, and the strict build check. The merged modernization branches
and obsolete legacy branches have been removed; the old `v01` history is
preserved by the `archive-v01-2017` tag. An additional link checker remains
optional.

### 3. Introduce production deployment separately

Create deployment as a separate reviewed change; do not add deployment
Expand All @@ -89,11 +95,16 @@ permissions to the validation workflow.
analytics, mobile layout, and important external links.
- Document how to restore the existing `gh-pages` version before retiring that
publishing path.
- After the first release is accepted, enable deployment following successful
changes to `master`.
- Keep publishing manual after the first release unless automatic deployment
is explicitly preferred later.
- Remove the legacy configuration backups only after the production site has
been stable and the rollback procedure is documented.

**Progress:** the manually triggered workflow is prepared on the
`pages-deployment` branch. It must pass pull-request validation, be merged,
and then be enabled and exercised deliberately through the GitHub Pages
settings and Actions interface.

**Milestone exit criterion:** the Jupyter Book 2 site is live, important routes
are verified, deployment is reproducible, and a failed build cannot replace the
working site.
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ repository permission and does not deploy or modify the live website.

## Publishing

The live GitHub Pages site is currently maintained separately on the
`gh-pages` branch. During the migration, review changes through the local
preview and do not replace the production build until the new site has been
approved.
The live site is still served from the legacy `gh-pages` branch until the
first Jupyter Book 2 deployment is approved. The intended replacement is the
manual `Deploy website` workflow in `.github/workflows/deploy.yml`.

After the workflow has been merged and GitHub Pages has been configured to use
GitHub Actions, publish an approved `master` revision from the repository's
**Actions** tab: select **Deploy website**, choose **Run workflow**, confirm
`master`, and start the run. The workflow performs a new locked strict build
and deploys only the generated HTML. It does not modify `gh-pages`.

Merging a pull request does not trigger this workflow. Everything merged into
`master` should nevertheless be safe to include in the next manual release.
Loading