Skip to content

Conversation

@thomasht86
Copy link
Owner

The site/ directory built by mkdocs was lost when switching to gh-pages branch. Now backup to /tmp/site-backup before the branch switch and restore from there, matching the existing benchmark data backup pattern.

The site/ directory built by mkdocs was lost when switching to gh-pages
branch. Now backup to /tmp/site-backup before the branch switch and
restore from there, matching the existing benchmark data backup pattern.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@thomasht86 thomasht86 enabled auto-merge January 20, 2026 13:11
@claude
Copy link

claude bot commented Jan 20, 2026

PR Review: fix: backup site/ directory before branch switch in mkdocs workflow

Summary

This PR fixes a bug in the mkdocs deployment workflow where the site/ directory was being lost when switching to the gh-pages branch. The fix backs up the directory to /tmp/site-backup before the branch switch, matching the existing pattern used for benchmark data.


Positive Feedback

  1. Correct Problem Identification: The issue is real - git checkout gh-pages clears the working directory, including the freshly built site/ folder from line 33.

  2. Consistent Pattern: The solution mirrors the existing benchmark data backup pattern (lines 46-56), maintaining consistency in the codebase.

  3. Good Error Handling: The validation check (lines 65-68) ensures the backup exists before attempting to copy it.

  4. Clear Commit Message: Follows conventional commits format and includes a co-author attribution.


Code Quality Review

The fix is simple and straightforward - backs up site/ to /tmp/site-backup before branch switch, then restores from backup. Quality assessment: Good - proper validation before use and matches existing patterns.


Potential Issues and Suggestions

1. Error Message Accuracy (Minor) - Line 66: The error message says "Error: site/ directory is empty or missing" but it's actually checking /tmp/site-backup. Consider: "Error: /tmp/site-backup directory is empty or missing (mkdocs build may have failed)"

2. Cleanup Consideration (Enhancement): The /tmp/site-backup directory persists after workflow completion. While not critical in CI environments (fresh runners each time), cleanup would be more hygienic. Optional: add rm -rf /tmp/site-backup at the end. Very low priority.

3. Defensive Check (Belt-and-suspenders): Consider verifying the site/ directory exists before backing it up. This would catch mkdocs build failures earlier with a clearer error message.


Security Review

No security concerns identified - uses /tmp appropriately for CI, no user input handling, no credential exposure, proper GitHub Actions permissions.


Test Coverage

No automated tests for GitHub Actions workflows (normal for most projects). The fix can be validated by checking that the next docs deployment successfully publishes to gh-pages. Consider triggering a manual workflow run to validate.


Overall Assessment

Status: APPROVE with minor suggestions

This is a solid fix that correctly addresses the identified issue. The implementation is clean, follows existing patterns, and doesn't introduce any bugs or security concerns.

Recommended Actions:

  1. Merge as-is - The PR is good enough to merge
  2. Optional: Consider the error message improvement for better debugging
  3. Optional: Add early validation of site/ directory before backup

Risk Level: Very Low
Merge Confidence: High


Great work fixing this! The approach is sound and the implementation is clean.

@thomasht86 thomasht86 merged commit 1a92887 into main Jan 20, 2026
19 checks passed
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.

2 participants