GitHub Pages Setup Guide for datason¶
🚀 Overview¶
This guide explains how to set up GitHub Pages for datason documentation and resolve common permission issues with GitHub Actions deployment.
🔧 Repository Setup¶
Step 1: Enable GitHub Pages¶
- Go to your repository settings:
https://github.com/danielendler/datason/settings
- Scroll down to "Pages" section
- Under "Source", select "GitHub Actions" (not the legacy "Deploy from a branch")
- Click "Save"
Step 2: Configure Repository Permissions¶
- Go to Settings → Actions → General
- Under "Workflow permissions", select:
- ✅ "Read and write permissions"
- ✅ "Allow GitHub Actions to create and approve pull requests"
- Click "Save"
Step 3: Verify Environment Protection (Optional)¶
- Go to Settings → Environments
- If
github-pages
environment exists, ensure it's configured correctly - If not, it will be created automatically on first deployment
🏗️ Modern GitHub Pages Workflow¶
Our updated .github/workflows/docs.yml
now uses the modern GitHub Pages workflow with:
Key Improvements¶
- ✅ Official GitHub Actions: Uses
actions/configure-pages@v4
andactions/deploy-pages@v4
- ✅ Proper Permissions: Workflow-level permissions for Pages deployment
- ✅ Concurrency Control: Prevents multiple simultaneous deployments
- ✅ Environment Protection: Uses
github-pages
environment for deployment tracking
Workflow Features¶
# Workflow-level permissions (most secure)
permissions:
contents: read
pages: write
id-token: write
# Concurrency control
concurrency:
group: "pages"
cancel-in-progress: false
# Environment for deployment tracking
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
🐛 Troubleshooting Common Issues¶
1. Permission Denied Error¶
remote: Permission to danielendler/datason.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/danielendler/datason.git/': The requested URL returned error: 403
Solution:
- ✅ Enable "Read and write permissions" in repository settings
- ✅ Use the modern GitHub Pages workflow (not peaceiris/actions-gh-pages
)
- ✅ Set GitHub Pages source to "GitHub Actions"
2. Environment Protection Rules¶
Solution: - ✅ Check Settings → Environments → github-pages - ✅ Ensure workflow has proper permissions - ✅ Add required reviewers if needed for protection
3. Pages Build Failure¶
Solution:
- ✅ Ensure Pages source is set to "GitHub Actions"
- ✅ Check that mkdocs build --strict
passes locally
- ✅ Verify all documentation links are valid
4. Workflow Not Triggering¶
Solution: - ✅ Check path filters in workflow trigger:
- ✅ Ensure changes are in tracked paths - ✅ Push tomain
branch for deployment
📋 Workflow Breakdown¶
Build Stage¶
build-docs:
# Runs on all PRs and pushes
# Validates documentation builds correctly
# Uploads artifact for later deployment
Deploy Stage¶
deploy-github-pages:
# Only runs on main branch pushes
# Uses modern GitHub Pages actions
# Deploys to github-pages environment
🚀 Deployment Process¶
Automatic Deployment¶
- Push to main with documentation changes
- Build job validates and creates artifact
- Deploy job publishes to GitHub Pages
- Site available at
https://danielendler.github.io/datason/
Manual Deployment¶
🔍 Monitoring & Debugging¶
Check Deployment Status¶
# View workflow runs
gh run list --workflow=docs.yml
# View specific run details
gh run view <run-id>
# Watch live run
gh run watch
Verify Pages Configuration¶
Test Documentation Locally¶
# Install dependencies
pip install -e ".[docs]"
# Serve locally
mkdocs serve
# Build and check
mkdocs build --strict
📚 Alternative Solutions¶
Option 1: Personal Access Token (if above doesn't work)¶
- Create PAT with
repo
andworkflow
permissions - Add as repository secret
PAGES_DEPLOY_TOKEN
- Use in workflow:
Option 2: GitHub App Token¶
For organization repositories with stricter security: 1. Create GitHub App with Pages permissions 2. Install app on repository 3. Use app token for deployment
🔐 Security Considerations¶
Minimal Permissions¶
Our workflow uses minimal required permissions:
- contents: read
- Read repository content
- pages: write
- Deploy to GitHub Pages
- id-token: write
- OIDC token for Pages deployment
Environment Protection¶
- Deployments tracked in
github-pages
environment - Optional: Add required reviewers for production
- Automatic deployment logs and history
📖 Additional Resources¶
- GitHub Pages Documentation
- GitHub Actions for Pages
- MkDocs Documentation
- datason Documentation Source
💡 Need Help? Create an issue if you encounter problems with documentation deployment.