Skip to content

[Maintenance] Unify PR deploy-previews onto quantecon/actions/preview-netlify (safe first rollout of shared actions) #327

Open

Description

@mmcky

Summary

Unify the PR deploy-preview mechanism across the Python lecture repos onto the shared composite action quantecon/actions/preview-netlify, pinned at @v0.6.0.

Today the preview step is configured inconsistently: most repos call nwtgck/actions-netlify directly at drifting versions (@v3, @v3.0, @v1.1), two repos deploy a duplicate preview from collab.yml, one repo has no preview at all, and only lecture-python.myst has adopted the shared action.

This is deliberately scoped as a safe first deployment of our shared-action stack: the preview step is build-agnostic (it only consumes _build/html), so a broken migration breaks previews (cosmetic, non-blocking) rather than builds (which would block every PR and publish). The broader migration of each repo onto the full quantecon/actions/* stack (setup-environment, restore-jupyter-cache, build-lectures, publish-gh-pages) is Track 2 and explicitly out of scope here — see Out of scope.

Why now

  • Ends version drift. One pinned version (@v0.6.0) instead of @v3 / @v3.0 / @v1.1.
  • One place to maintain. The shared action is a from-scratch reimplementation (Netlify CLI + actions/github-script), not a wrapper — CLI/behavior changes get fixed once, centrally.
  • Better reviewer UX. Deterministic preview URLs (pr-<N> alias) and a single self-updating PR comment that links directly to the changed lecture pages.
  • De-risks Track 2. Getting preview-netlify adopted everywhere first makes it a known-good shared-action consumer in each repo before we touch the riskier build internals.

Current state (audit, June 2026)

Repo Preview today Action / version Production path On quantecon/actions?
lecture-python.myst Netlify ✅ quantecon/actions/[email protected] gh-pages (peaceiris) preview only — reference
lecture-dp none — ✅ quantecon/actions/[email protected] fully (cache/build/publish)
lecture-python-intro Netlify ×3 nwtgck/[email protected] gh-pages + Netlify mirror no
lecture-jax Netlify ×2 nwtgck/actions-netlify@v3 gh-pages (peaceiris) no
lecture-python-programming Netlify nwtgck/actions-netlify@v3 GitHub Pages (native) no
lecture-python-advanced.myst Netlify nwtgck/actions-netlify@v3 gh-pages (peaceiris) no
continuous_time_mcs Netlify nwtgck/[email protected] gh-pages (peaceiris) no

Resolved decisions

  1. Version pin: exact @v0.6.0 in every repo (matching lecture-python.myst) + Dependabot to bump. The moving @v0 tag is not used — it currently lags (points at the v0.5.2 commit, not v0.6.0).
  2. Duplicate previews (lecture-python-intro, lecture-jax): drop the preview from collab.yml so it stays a pure Colab execution test; only ci.yml deploys a preview. One preview + one comment per PR.
  3. lecture-python-intro Netlify production mirror (publish.yml): retire it as part of this work — gh-pages (intro.quantecon.org) remains the canonical production site; the redundant Netlify production deploy is removed.
  4. lecture-dp: include as net-new — provision a Netlify site + repo secrets and add preview-netlify to its ci.yml, bringing it to parity.

Target state

Every repo's PR preview is a single step:

      - name: Preview Deploy to Netlify
        uses: quantecon/actions/[email protected]
        with:
          netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          netlify-site-id: ${{ secrets.NETLIFY_SITE_ID }}
          build-dir: _build/html

Per-repo migration checklist (common steps)

  • Replace the nwtgck/actions-netlify@… step in ci.yml with the shared-action step above.
  • Add job-level permissions: { contents: read, pull-requests: write } (needed for the PR comment).
  • Ensure the actions/checkout step uses fetch-depth: 0 (needed for changed-page detection).
  • Ensure Node is available before the step (the action npm i -g netlify-cli); add actions/setup-node@v6 if the job doesn't already have Node, as the reference repo does.
  • Disable Netlify's native GitHub-App PR comments on the site so we don't get two comments per PR.

Behavioral changes to expect

  • Preview-only. This action never does a production deploy (no --prod). Production paths (gh-pages) are untouched.
  • Deterministic URL: alias hardcoded to pr-<PR#> (most repos currently get random URLs).
  • PR comment: a single self-updating 📖 Netlify Preview Ready! comment with changed-page links, replacing the nwtgck comment.
  • dependabot + fork PRs auto-skip the preview (they can't read secrets) — they get a skip log line instead of a failure.

Rollout (easy → hard)

  • 1. continuous_time_mcs — swap the single ci.yml preview step. (pilot)
  • 2. lecture-python-advanced.myst — swap the single ci.yml preview step. (pilot)
  • 3. lecture-python-programming — swap ci.yml; delete the stale .github/workflows/_github_actions/ dir (dead @v1.1 copy).
  • 4. lecture-jax — swap ci.yml; drop the duplicate preview from collab.yml.
  • 5. lecture-python-intro — swap ci.yml; drop the duplicate preview from collab.yml; retire the Netlify production mirror in publish.yml (gh-pages remains canonical).
  • 6. lecture-dp — net-new: provision a Netlify site + repo secrets (NETLIFY_SITE_ID; confirm NETLIFY_AUTH_TOKEN is available), then add preview-netlify to ci.yml.
  • lecture-python.myst — already done (reference). Minor cleanup: remove the unused preview_page workflow_dispatch input.

Out of scope / follow-ups

  • Track 2 — full quantecon/actions/* adoption per repo (setup-environment, restore-jupyter-cache, build-lectures, publish-gh-pages). Bigger and riskier: these repos have bespoke pipelines (RunsOn GPU AMIs, JAX[cuda], LaTeX PDF, Colab containers). Gating question: do the shared build/setup composites absorb those quirks? lecture-dp is the working template (though it's non-GPU). To be tracked separately.
  • Re-point the @v0 moving tag in QuantEcon/actions to v0.6.0 (it currently lags at the v0.5.2 commit). Not needed for this project since we pin exact versions, but worth fixing as a small standalone task.
  • Standardizing the production publish path (gh-pages variants across repos) — separate effort.

References


Audit performed June 2026 across the 6 Python lecture repos + continuous_time_mcs and the QuantEcon/actions composite actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions