2.0 KiB
2.0 KiB
PR Preview Setup Guide
This document describes the repository settings required for PR previews to work.
Required Repository Settings
1. GitHub Pages Configuration
Go to Settings > Pages and configure:
- Source: Deploy from a branch
- Branch:
gh-pages// (root)
The gh-pages branch will be created automatically on the first preview deployment.
2. Actions Permissions
Go to Settings > Actions > General and configure:
- Workflow permissions: Read and write permissions
- Allow GitHub Actions to create and approve pull requests: ✓ (checked)
3. Branch Protection (Optional)
If you have branch protection on gh-pages, ensure GitHub Actions can push:
- Allow force pushes: GitHub Actions
- Or add a bypass for the
github-actions[bot]user
How It Works
-
When a PR is opened/updated with changes to
content/,layouts/,assets/,data/,api-docs/, oropenapi/:- The workflow detects which pages are affected
- Hugo builds the full site
- Only affected pages are copied to a staging directory
- The staging directory is deployed to
gh-pagesunderpr-preview/pr-{number}/
-
A sticky comment is posted on the PR with the preview link
-
When the PR is closed/merged:
- The preview directory is removed from
gh-pages - The PR comment is deleted
- The preview directory is removed from
-
Weekly cleanup removes any orphaned previews
Preview URL Format
https://influxdata.github.io/docs-v2/pr-preview/pr-{number}/
Troubleshooting
Preview not deploying
- Check if the PR is a draft (drafts don't get previews)
- Check if the changed files match the trigger paths
- Check the workflow run logs for errors
Preview shows 404
- The page might not be included in the preview (check PR comment for page list)
- The preview might still be deploying (wait a few minutes)
- GitHub Pages might have caching (try hard refresh)
Cleanup not working
- Check if the
gh-pagesbranch exists - Verify Actions have write permissions
- Run the cleanup workflow manually via Actions tab