This repository uses GitHub Actions to automatically deploy the DIIP documentation to GitHub Pages with simultaneous deployments maintained for different branches and pull requests.
| Branch | Deployment Location | URL Pattern |
|---|---|---|
main |
Root directory (/) |
https://FIDEScommunity.github.io/DIIP |
develop |
/draft directory |
https://FIDEScommunity.github.io/DIIP/draft |
| Pull Requests | /pr/pr-{number} directory |
https://FIDEScommunity.github.io/DIIP/pr/pr-123 |
Key Feature: All deployments are maintained simultaneously - deploying to one branch does NOT overwrite others.
The workflow manually manages the gh-pages branch instead of using GitHub's standard deploy-pages action, which would overwrite the entire site. This ensures:
- Main branch deployment preserves draft and PR previews
- Develop branch deployment preserves main and PR previews
- PR deployments preserve all other deployments
- Each deployment only updates its specific directory
- Deploys to the root of GitHub Pages (
/) - Also creates a copy at
/latestfor backwards compatibility - Preserves all existing
/draftand/pr/subdirectories - Represents the stable, published version of DIIP
- Deploys to
/draftsubdirectory only - Preserves root content and all
/pr/directories - Creates a commit status on the latest commit with the preview URL
- Used for reviewing upcoming changes before they go to main
- Each PR gets its own isolated subdirectory:
/pr/pr-{number} - Preserves all other deployments (main, draft, other PRs)
- Comments on the PR with the preview URL
- Updates the comment when new commits are pushed
- Automatically cleans up only its own directory when closed/merged
# The workflow:
1. Checks out both source branch and gh-pages branch
2. Updates only the target directory (., draft/, or pr/pr-N/)
3. Preserves all other directories
4. Commits and pushes only the specific changes- Root deployment (main): Updates
*.html,assets/, etc. but preservesdraft/andpr/subdirs - Subdirectory deployment: Only updates the specific subdirectory
- Cleanup: Only removes the specific PR directory when closed
gh-pages branch:
├── README.md (setup instructions)
├── index.html (main branch - stable)
├── latest.html (copy of main branch)
├── assets/ (main branch assets)
├── custom-assets/ (main branch assets)
├── draft/ (develop branch)
│ ├── index.html
│ ├── assets/
│ └── custom-assets/
└── pr/ (PR previews)
├── pr-123/ (PR #123)
│ ├── index.html
│ ├── assets/
│ └── custom-assets/
├── pr-456/ (PR #456)
│ ├── index.html
│ ├── assets/
│ └── custom-assets/
└── pr-789/ (PR #789)
├── index.html
├── assets/
└── custom-assets/
The workflow requires the following permissions:
contents: write- To manage the gh-pages branch manuallypull-requests: write- To comment on pull requests
Due to GitHub API permission limitations, GitHub Pages must be enabled manually:
-
One-time setup: After the first workflow run:
- Go to repository Settings > Pages
- Under Source, select Deploy from a branch
- Select branch gh-pages and folder / (root)
- Click Save
-
Verification: The workflow will automatically detect if Pages is enabled and provide setup instructions if needed
-
Branch Protection (recommended): Protect the
mainbranch to ensure only reviewed changes are deployed to production
- Creates gh-pages branch if it doesn't exist
- Provides setup instructions in the branch README
- Detects Pages status and shows appropriate messages
- Workflow summaries with setup guidance when needed
- Concurrency Group:
pages-${{ github.ref }}-${{ github.event.pull_request.number }} - Each branch/PR has its own deployment queue
- No conflicts between simultaneous deployments to different paths
- Safe parallel deployments of different branches/PRs
This error occurs when trying to enable GitHub Pages via API. Solution: Enable Pages manually as described above.
This usually means GitHub Pages isn't enabled yet. Solution: Follow the manual setup instructions above.
GitHub Pages may take a few minutes to update after deployment. Check the Pages settings to ensure it's pointing to the gh-pages branch.
The workflow handles all maintenance automatically:
- No overwrites: Each deployment only touches its own directory
- Automatic cleanup: PR directories removed when PRs close
- Preserves history: All deployments remain available
- Self-healing: Creates gh-pages branch if missing
- Idempotent: Safe to re-run without side effects
- Clear feedback: Provides setup instructions when needed