|
| 1 | +# Website Deployment |
| 2 | + |
| 3 | +This document describes the deployment configuration for the pgflow documentation website. |
| 4 | + |
| 5 | +## Deployment Target |
| 6 | + |
| 7 | +The website is deployed to **Cloudflare Pages** via GitHub Actions workflow. |
| 8 | + |
| 9 | +- **Production URL**: https://www.pgflow.dev |
| 10 | +- **Preview URLs**: https://pr-{number}.pgflow.pages.dev (for pull requests) |
| 11 | + |
| 12 | +## Required GitHub Secrets |
| 13 | + |
| 14 | +The following secrets must be configured in the GitHub repository (Settings → Secrets and variables → Actions). |
| 15 | + |
| 16 | +**Note**: Some secrets are namespaced (e.g., `WEBSITE_*`) at the GitHub level but are mapped to simpler names (e.g., `VITE_*`, `PLAUSIBLE_PROXY_URL`) when passed as environment variables to the build process. |
| 17 | + |
| 18 | +### Cloudflare Configuration |
| 19 | + |
| 20 | +- **`CLOUDFLARE_API_TOKEN`** |
| 21 | + - **GitHub Secret Name**: `CLOUDFLARE_API_TOKEN` |
| 22 | + - **Environment variable**: `CLOUDFLARE_API_TOKEN` |
| 23 | + - API token for deploying to Cloudflare Pages |
| 24 | + |
| 25 | +- **`CLOUDFLARE_ACCOUNT_ID`** |
| 26 | + - **GitHub Secret Name**: `CLOUDFLARE_ACCOUNT_ID` |
| 27 | + - **Environment variable**: `CLOUDFLARE_ACCOUNT_ID` |
| 28 | + - Cloudflare account ID |
| 29 | + |
| 30 | +### Supabase Configuration |
| 31 | + |
| 32 | +Website deployment requires Supabase configuration for both preview and production environments: |
| 33 | + |
| 34 | +**Preview Environment:** |
| 35 | +- **`WEBSITE_PREVIEW_SUPABASE_URL`** |
| 36 | + - **GitHub Secret Name**: `WEBSITE_PREVIEW_SUPABASE_URL` |
| 37 | + - **Maps to environment variable**: `VITE_SUPABASE_URL` (in preview deployments) |
| 38 | + - Supabase project URL for preview deployments |
| 39 | + |
| 40 | +- **`WEBSITE_PREVIEW_SUPABASE_ANON_KEY`** |
| 41 | + - **GitHub Secret Name**: `WEBSITE_PREVIEW_SUPABASE_ANON_KEY` |
| 42 | + - **Maps to environment variable**: `VITE_SUPABASE_ANON_KEY` (in preview deployments) |
| 43 | + - Supabase anonymous key for preview deployments |
| 44 | + |
| 45 | +**Production Environment:** |
| 46 | +- **`WEBSITE_PRODUCTION_SUPABASE_URL`** |
| 47 | + - **GitHub Secret Name**: `WEBSITE_PRODUCTION_SUPABASE_URL` |
| 48 | + - **Maps to environment variable**: `VITE_SUPABASE_URL` (in production deployments) |
| 49 | + - Supabase project URL for production |
| 50 | + |
| 51 | +- **`WEBSITE_PRODUCTION_SUPABASE_ANON_KEY`** |
| 52 | + - **GitHub Secret Name**: `WEBSITE_PRODUCTION_SUPABASE_ANON_KEY` |
| 53 | + - **Maps to environment variable**: `VITE_SUPABASE_ANON_KEY` (in production deployments) |
| 54 | + - Supabase anonymous key for production |
| 55 | + |
| 56 | +### Analytics Configuration |
| 57 | + |
| 58 | +- **`WEBSITE_PLAUSIBLE_PROXY_URL`** - Cloudflare Workers proxy URL for Plausible Analytics (website-specific) |
| 59 | + - **GitHub Secret Name**: `WEBSITE_PLAUSIBLE_PROXY_URL` |
| 60 | + - **Maps to environment variable**: `PLAUSIBLE_PROXY_URL` (used in `astro.config.mjs`) |
| 61 | + - Example value: `https://your-worker-name.your-username.workers.dev` |
| 62 | + - This proxies requests to Plausible to avoid ad blockers |
| 63 | + - If this URL becomes invalid, Plausible tracking will stop working |
| 64 | + - Note: This is separate from demo app analytics which uses its own proxy URL |
| 65 | + |
| 66 | +## Deployment Workflow |
| 67 | + |
| 68 | +The deployment is handled by the `deploy-website` job in `.github/workflows/ci.yml`: |
| 69 | + |
| 70 | +1. **Trigger**: Runs on push to `main` or when a pull request is opened/updated |
| 71 | +2. **Affected Check**: Only deploys if the website package is affected by changes (using Nx) |
| 72 | +3. **Build**: Builds the website with environment variables injected |
| 73 | +4. **Deploy**: |
| 74 | + - Production: Deploys to main branch on Cloudflare Pages |
| 75 | + - Preview: Deploys to PR-specific branch on Cloudflare Pages |
| 76 | + |
| 77 | +## Local Development |
| 78 | + |
| 79 | +For local development, the Plausible proxy URL falls back to a hardcoded value in `astro.config.mjs` if the `PLAUSIBLE_PROXY_URL` environment variable is not set. |
| 80 | + |
| 81 | +To test with a specific proxy URL locally: |
| 82 | + |
| 83 | +```bash |
| 84 | +PLAUSIBLE_PROXY_URL=https://your-worker.your-username.workers.dev pnpm nx dev website |
| 85 | +``` |
| 86 | + |
| 87 | +## Troubleshooting |
| 88 | + |
| 89 | +### Plausible Analytics Not Tracking |
| 90 | + |
| 91 | +If Plausible stops tracking visitors: |
| 92 | + |
| 93 | +1. Check if the Cloudflare Workers proxy URL is accessible: |
| 94 | + ```bash |
| 95 | + curl -I https://your-worker-name.your-username.workers.dev/assets/script.hash.outbound-links.pageview-props.tagged-events.js |
| 96 | + ``` |
| 97 | + |
| 98 | +2. If the URL fails (DNS resolution error or 404), update the `WEBSITE_PLAUSIBLE_PROXY_URL` secret in GitHub with the correct URL |
| 99 | + |
| 100 | +3. The proxy URL may change if the Cloudflare Workers username changes |
| 101 | + |
| 102 | +4. After updating the secret, redeploy the website (push to `main` or re-run the workflow) |
| 103 | + |
| 104 | +### Deployment Fails |
| 105 | + |
| 106 | +- Verify all required secrets are configured in GitHub |
| 107 | +- Check the GitHub Actions workflow logs for specific error messages |
| 108 | +- Ensure the Cloudflare API token has the necessary permissions (Account → Cloudflare Pages - Edit) |
0 commit comments