Fix multiversion docs overwrite on main push#266
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>
Root cause: actions/deploy-pages always replaces the entire site with whatever artifact is uploaded. A per-ref cache only restored the current branch's output, so a main push deployed a site with only main/ and wiped all versioned docs. Fix: use a shared cross-ref cache (docs-full-site-<repo>-<run_id>) with a common restore-key prefix. Every build job: 1. Restores the last saved full site (all versions) 2. Rebuilds only the current version subdir (main/ or v*) 3. Prunes excess tag versions when on a tag push 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. Reverts the JamesIves gh-pages branch approach (user prefers GitHub Actions source for Pages deployment). Test: 3 act scenarios all pass: - main push: v0.1.0 and v0.2.0 survive, main/ updated - tag push: new version added, existing dirs untouched - prune: 5th tag causes oldest to be removed, max 4 tags kept 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 original per-ref cache (docs-output-${{ github.ref_name }}) only stored the current branch's output, so eachmainpush deployed an artifact with onlymain/— erasing all previously deployed versioned dirs likev0.2.0/.Fix: Maintain a single shared cross-ref cache (
docs-full-site-<repo>-<run_id>) with a common restore-key prefix. Every build job:main/orv*/)DOCS_MAX_VERSIONS=4versions.jsonand rootindex.htmlfrom all present dirsactions/deploy-pagesthen deploys the full site — all versions intact. No GitHub Pages source setting change required (stays on "GitHub Actions").Type of change
Checklist
black .command to format the code base.Tests —
.github/workflows/tests/test_docs_publish.ymlwith 3actscenarios, all pass ✅:test-main-push:v0.1.0andv0.2.0survive aftermainpush,main/is 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