Fix PR preview 404s - Deploy via gh-pages branch#15
Conversation
Co-authored-by: D4koon <13141819+D4koon@users.noreply.github.com>
Co-authored-by: D4koon <13141819+D4koon@users.noreply.github.com>
|
@copilot https://d4koon.github.io/Holiday-Planner/ does work for me and does show the state of the main branch |
Great! The main site at https://d4koon.github.io/Holiday-Planner/ is working correctly. For GitHub Pages configuration, the repository should be set to deploy from the If PR preview URLs aren't accessible, it might be because:
Can you confirm whether PR preview URLs like |
|
@copilot I changed a setting now can you cleanup all preview workflows i only want one |
Co-authored-by: D4koon <13141819+D4koon@users.noreply.github.com>
Done! Removed To test if PR previews work:
The main site ( |
|
@copilot Im not sure whats going on but you are assuming the page https://d4koon.github.io/Holiday-Planner/ is serverd from the branch gh-pages, which is not the case, im not sure from where it is served... |
You're absolutely right! I misunderstood the setup. The The issue is that Two options to fix this:
Which approach would you prefer? If you want PR previews to work, option 2 is needed. |
…flow Co-authored-by: D4koon <13141819+D4koon@users.noreply.github.com>
|
@copilot i changed the page-settings now to serve the gh-pages branch, update all workflows accordingly |
Co-authored-by: D4koon <13141819+D4koon@users.noreply.github.com>
Done! Added Workflows configured for gh-pages deployment:
After merging:
|
Co-authored-by: D4koon <13141819+D4koon@users.noreply.github.com>
🎉 Preview Deployed!Your PR preview is ready for review: 🔗 Preview URL: https://D4koon.github.io/Holiday-Planner/pr-15/ The preview will automatically update with new commits. |
🧹 Preview Cleaned UpThe preview for this PR has been removed since the PR was closed. |
The repository was using GitHub's native Pages deployment via
static.ymlworkflow, while thepr-preview.ymlworkflow was deploying PR previews to the gh-pages branch. These two deployment methods conflicted, causing 404s at URLs likehttps://d4koon.github.io/Holiday-Planner/pr-13/.After updating GitHub Pages settings to serve from the gh-pages branch, all workflows have been updated to use the gh-pages branch deployment method.
Issue Identified
The main site was deployed using
static.ymlwith GitHub Actions native deployment (actions/deploy-pages@v4), while PR previews were attempting to deploy to the gh-pages branch. These two deployment methods conflict - GitHub Pages can only serve from one source at a time.Changes Made
Added
deploy-main.ymlworkflow - Deploys main branch to gh-pages root on push to main, preserving PR preview directories viakeep_files: trueFixed redirect URLs - Changed
url=../../tourl=../in closed PR redirect pages inpr-preview.ymlhttps://d4koon.github.io/(user's root GitHub Pages)https://d4koon.github.io/Holiday-Planner/(project site)Removed
fix-pr-12-preview.ymlworkflow - Consolidated to single PR preview workflow (pr-preview.yml)PR preview workflow - Already configured to deploy to gh-pages branch subdirectories (
pr-<number>/)Deployment Architecture
Both workflows now use
peaceiris/actions-gh-pages@v3to deploy to the gh-pages branch:Next Steps
After merging this PR:
static.ymlworkflow on main should be removed (no longer needed)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.