Skip to content

Fix multiversion docs overwrite on main branch push#263

Merged
yuecideng merged 1 commit into
mainfrom
fix/docs-multiversion-overwrite
May 12, 2026
Merged

Fix multiversion docs overwrite on main branch push#263
yuecideng merged 1 commit into
mainfrom
fix/docs-multiversion-overwrite

Conversation

@yuecideng
Copy link
Copy Markdown
Contributor

@yuecideng yuecideng commented May 12, 2026

Description

This PR fixes a bug where pushing to main wiped all versioned documentation from GitHub Pages, leaving only the main/ subdirectory.

Root cause: actions/deploy-pages@v4 always performs a full site replacement. The per-ref cache only stored the current branch output, so each main push deployed a site with only main/ — erasing all versioned dirs like v0.2.0/.

Fix: Use a shared cross-ref cache (docs-full-site-<repo>-<run_id>). Every build:

  1. Restores the last saved full multi-version site from cache
  2. Rebuilds only the current version subdir (main/ or v*/)
  3. Prunes excess tag versions (on tag push, max DOCS_MAX_VERSIONS=4)
  4. Regenerates versions.json and root index.html
  5. Saves the updated full site back to cache
  6. Uploads the complete multi-version site as the pages artifact

actions/deploy-pages then deploys the full site — all versions intact. No branch settings change required.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have run the black . command to format the code base.
  • I have added tests that prove my fix is effective or that my feature works

Tests (3 act scenarios, all pass ✅):

  • test-main-push: v0.1.0 and v0.2.0 survive after main push, main/ updated
  • test-tag-push: New tag version added, all existing dirs preserved
  • test-prune-old-versions: 5th tag causes oldest to be removed, max 4 tags kept

🤖 Generated with GitHub Copilot

Root cause: actions/deploy-pages@v4 does a full site replacement.
A main branch push only built main/, so every deploy wiped out all
versioned docs (v0.2.0, etc.) deployed via tag pushes.

Fix:
- Remove the per-ref docs cache from the build job (it only stored
  the current ref's subdir, making the full-replace worse).
- Switch from actions/upload-pages-artifact + actions/deploy-pages
  to JamesIves/github-pages-deploy-action@v4 with target-folder +
  clean: true, which updates only the specific subdirectory in the
  gh-pages branch leaving all other version dirs untouched.
- Move version pruning and metadata regeneration (versions.json,
  root index.html) into the publish job where the full gh-pages
  state is always visible.

Required repo-settings change: GitHub Pages source must be changed
from 'GitHub Actions' to 'Deploy from branch: gh-pages'.

Add .github/workflows/tests/test_docs_publish.yml with three act-
testable scenarios (main push, tag push, prune) all verified passing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yuecideng yuecideng merged commit a251699 into main May 12, 2026
5 of 6 checks passed
@yuecideng yuecideng deleted the fix/docs-multiversion-overwrite branch May 12, 2026 08:46
@yuecideng yuecideng restored the fix/docs-multiversion-overwrite branch May 12, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant