From 69e47eca2ce021268748aa37257930e244209169 Mon Sep 17 00:00:00 2001 From: Rafael Camacho Date: Thu, 24 Sep 2026 17:42:03 +0200 Subject: [PATCH] Add manual GitHub Pages deployment --- .github/workflows/deploy.yml | 116 +++++++++++++++++++++++++++++++++++ PLAN.md | 15 ++++- README.md | 16 +++-- 3 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..5939cd8 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/PLAN.md b/PLAN.md index 83c9208..2cdd3d4 100644 --- a/PLAN.md +++ b/PLAN.md @@ -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 @@ -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. diff --git a/README.md b/README.md index 7416f2c..659a5c6 100644 --- a/README.md +++ b/README.md @@ -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.