|
| 1 | +# Documentation Deployment Setup |
| 2 | + |
| 3 | +This document explains how to set up automatic documentation deployment to Netlify when merging to master or when using the "docs" label on pull requests. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The project uses GitHub Actions to automatically build and deploy documentation to Netlify in two scenarios: |
| 8 | + |
| 9 | +1. **Production Deployment**: When changes are merged to the master branch |
| 10 | +2. **Preview Deployment**: When a pull request has the "docs" label |
| 11 | + |
| 12 | +The documentation is generated using TypeDoc and includes API documentation, coverage reports, and interactive navigation. |
| 13 | + |
| 14 | +## Deployment Triggers |
| 15 | + |
| 16 | +### Production Deployment |
| 17 | +- Automatically triggers on pushes to `master` or `main` branches |
| 18 | +- Deploys to the production Netlify site |
| 19 | +- Updates the main documentation URL |
| 20 | + |
| 21 | +### Preview Deployment |
| 22 | +- Triggers on pull requests with the "docs" label |
| 23 | +- Creates a preview deployment for testing documentation changes |
| 24 | +- Adds a comment to the PR with the preview URL |
| 25 | +- Perfect for reviewing documentation changes before merging |
| 26 | + |
| 27 | +## How to Use Preview Deployments |
| 28 | + |
| 29 | +1. Create a pull request with documentation changes |
| 30 | +2. Add the "docs" label to the pull request |
| 31 | +3. The workflow will automatically build and deploy a preview |
| 32 | +4. Check the PR comments for the preview URL |
| 33 | +5. Review the changes and merge when ready |
| 34 | + |
| 35 | +## Setup Instructions |
| 36 | + |
| 37 | +### 1. Netlify Setup |
| 38 | + |
| 39 | +1. Go to [Netlify](https://netlify.com) and sign in |
| 40 | +2. Create a new site (or use an existing one) |
| 41 | +3. Note down your **Site ID** from the site settings |
| 42 | +4. Generate a **Personal Access Token**: |
| 43 | + - Go to User Settings → Applications → Personal access tokens |
| 44 | + - Create a new token with appropriate permissions |
| 45 | + |
| 46 | +### 2. GitHub Secrets Configuration |
| 47 | + |
| 48 | +Add the following secrets to your GitHub repository: |
| 49 | + |
| 50 | +1. Go to your repository → Settings → Secrets and variables → Actions |
| 51 | +2. Add these repository secrets: |
| 52 | + |
| 53 | + - `NETLIFY_AUTH_TOKEN`: Your Netlify personal access token |
| 54 | + - `NETLIFY_SITE_ID`: Your Netlify site ID |
| 55 | + |
| 56 | +### 3. Workflow Configuration |
| 57 | + |
| 58 | +The deployment workflow is configured in `.github/workflows/deploy-docs.yml` and will: |
| 59 | + |
| 60 | +- Trigger on pushes to `master` and `main` branches (production) |
| 61 | +- Trigger on pull requests with the "docs" label (preview) |
| 62 | +- Build documentation using `yarn docs` |
| 63 | +- Deploy the generated docs to Netlify |
| 64 | +- Add appropriate comments with deployment status |
| 65 | + |
| 66 | +### 4. Netlify Configuration |
| 67 | + |
| 68 | +The `netlify.toml` file configures: |
| 69 | +- Publish directory (`docs`) |
| 70 | +- Redirect rules for better navigation |
| 71 | +- Cache headers for static assets |
| 72 | +- Security headers |
| 73 | + |
| 74 | +## Manual Deployment |
| 75 | + |
| 76 | +You can manually trigger documentation deployment by: |
| 77 | + |
| 78 | +1. Going to Actions tab in your GitHub repository |
| 79 | +2. Selecting "Deploy Documentation to Netlify" workflow |
| 80 | +3. Clicking "Run workflow" |
| 81 | + |
| 82 | +## Local Documentation Development |
| 83 | + |
| 84 | +To build documentation locally: |
| 85 | + |
| 86 | +```bash |
| 87 | +# Install dependencies |
| 88 | +yarn install |
| 89 | + |
| 90 | +# Generate documentation |
| 91 | +yarn docs |
| 92 | + |
| 93 | +# View documentation (served from ./docs directory) |
| 94 | +# You can use any static file server, for example: |
| 95 | +npx serve docs |
| 96 | +``` |
| 97 | + |
| 98 | +## Troubleshooting |
| 99 | + |
| 100 | +### Common Issues |
| 101 | + |
| 102 | +1. **Build fails**: Check that all dependencies are installed and TypeDoc configuration is correct |
| 103 | +2. **Deployment fails**: Verify Netlify secrets are correctly set in GitHub repository settings |
| 104 | +3. **Missing documentation**: Ensure TypeDoc is properly configured in `typedoc.config.mjs` |
| 105 | +4. **Preview not deploying**: Make sure the "docs" label is added to the pull request |
| 106 | + |
| 107 | +### Checking Deployment Status |
| 108 | + |
| 109 | +- View deployment logs in GitHub Actions |
| 110 | +- Check Netlify dashboard for deployment status |
| 111 | +- Review commit/PR comments for deployment notifications |
| 112 | + |
| 113 | +## Documentation Structure |
| 114 | + |
| 115 | +The generated documentation includes: |
| 116 | +- API reference for all exported functions and classes |
| 117 | +- Type definitions and interfaces |
| 118 | +- Coverage reports (if configured) |
| 119 | +- Interactive navigation and search |
| 120 | +- External links to React documentation |
0 commit comments