Fix multiversion docs overwrite on main branch push#263
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR fixes a bug where pushing to
mainwiped all versioned documentation from GitHub Pages, leaving only themain/subdirectory.Root cause:
actions/deploy-pages@v4always performs a full site replacement. The per-ref cache only stored the current branch output, so eachmainpush deployed a site with onlymain/— erasing all versioned dirs likev0.2.0/.Fix: Use a shared cross-ref cache (
docs-full-site-<repo>-<run_id>). Every build:main/orv*/)DOCS_MAX_VERSIONS=4)versions.jsonand rootindex.htmlactions/deploy-pagesthen deploys the full site — all versions intact. No branch settings change required.Type of change
Checklist
black .command to format the code base.Tests (3
actscenarios, all pass ✅):test-main-push:v0.1.0andv0.2.0survive aftermainpush,main/updatedtest-tag-push: New tag version added, all existing dirs preservedtest-prune-old-versions: 5th tag causes oldest to be removed, max 4 tags kept🤖 Generated with GitHub Copilot