feat: add GitHub Pages deployment for docs site#655
Conversation
- Configure next.config.mjs for static export (output, basePath, images) - Guard rewrites() behind !NEXT_STATIC_EXPORT to avoid incompatibility - Fix /api/search route to use fumadocs staticGET in static export mode - Add .github/workflows/docs.yml to build and deploy on push to main
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR enables static export of the documentation site and automates its deployment to GitHub Pages. The Next.js configuration is updated to generate static HTML, the search API is adapted to work in both static and dynamic modes, and a GitHub Actions workflow is added to automatically build and deploy the docs on changes. ChangesStatic Export and GitHub Pages Deployment
Sequence DiagramsequenceDiagram
participant Repo as Code Repository
participant Trigger as GitHub Actions
participant Build as Build Job
participant Bun as Bun Package Manager
participant NextJS as Next.js Export
participant Artifact as Artifact Storage
participant Deploy as Deploy Job
participant Pages as GitHub Pages
Repo->>Trigger: Push to main (docs/**)
Trigger->>Build: Start build job
Build->>Bun: bun install --frozen-lockfile
Bun->>Bun: Install dependencies
Build->>NextJS: bun run build (NEXT_STATIC_EXPORT=true)
NextJS->>NextJS: Generate static site to docs/out
Build->>Artifact: Upload docs/out as Pages artifact
Build->>Deploy: Job complete, trigger deploy
Deploy->>Artifact: Download Pages artifact
Deploy->>Pages: actions/deploy-pages@v4
Pages->>Pages: Deploy to /voicebox basePath
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/docs.yml:
- Around line 24-27: Replace mutable version tags for the listed GitHub Actions
with pinned commit SHAs: locate usages of actions/checkout@v4,
oven-sh/setup-pages-artifact@v2, actions/upload-pages-artifact@v3, and
actions/deploy-pages@v4 in the workflow and update each reference to the exact
commit SHA (e.g., actions/checkout@<commit-sha>) by finding the action string in
the YAML and substituting the tag with the corresponding trusted commit SHA from
the action's repository release history; ensure each updated entry still matches
the original action name and that the workflow syntax remains valid.
- Around line 11-14: The workflow currently sets broad permissions at the
top-level allowing pages: write and id-token: write for all jobs; change this to
least-privilege by keeping global permissions limited to contents: read (remove
pages: write and id-token: write from the global permissions block) and add a
per-job permissions block on the deploy job (the job named "deploy" that runs
actions/deploy-pages@v3) granting pages: write and id-token: write there; ensure
the build job retains only contents: read or no extra permissions.
In `@docs/app/api/search/route.ts`:
- Around line 9-11: Replace the truthy check on process.env.NEXT_STATIC_EXPORT
with an explicit comparison so the handler selection is deterministic: change
the conditional that sets GET (currently using process.env.NEXT_STATIC_EXPORT)
to compare against a specific string (e.g., process.env.NEXT_STATIC_EXPORT ===
"true") and use that result to pick between search.staticGET and search.GET;
update the assignment that defines GET (the exported const GET) accordingly so
it reliably chooses search.staticGET only when the env var is explicitly "true".
In `@docs/next.config.mjs`:
- Around line 7-20: The config sets output: 'export' unconditionally while
rewrites() is only added when !process.env.NEXT_STATIC_EXPORT, which conflicts
because static exports disallow rewrites; make both controlled by the same flag:
check process.env.NEXT_STATIC_EXPORT and only set output: 'export' when the flag
is truthy (or only set rewrites when the flag is falsy), so that output and
rewrites() are mutually consistent; update the top-level output property
(symbol: output) and the rewrites() block (symbol: rewrites) to be guarded by
the same NEXT_STATIC_EXPORT condition.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4e214ae9-da46-441b-bedf-0933b7fe948b
📒 Files selected for processing (3)
.github/workflows/docs.ymldocs/app/api/search/route.tsdocs/next.config.mjs
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: oven-sh/setup-bun@v2 | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n .github/workflows/docs.ymlRepository: jamiepine/voicebox
Length of output: 1440
Pin GitHub Actions to commit SHAs instead of mutable version tags.
The following GitHub Actions use version tags that could be moved upstream:
- Line 24:
actions/checkout@v4 - Line 26:
oven-sh/setup-pages-artifact@v2 - Line 39:
actions/upload-pages-artifact@v3 - Line 52:
actions/deploy-pages@v4
Replace these with specific commit SHAs to ensure supply-chain integrity for this deployment workflow.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/docs.yml around lines 24 - 27, Replace mutable version
tags for the listed GitHub Actions with pinned commit SHAs: locate usages of
actions/checkout@v4, oven-sh/setup-pages-artifact@v2,
actions/upload-pages-artifact@v3, and actions/deploy-pages@v4 in the workflow
and update each reference to the exact commit SHA (e.g.,
actions/checkout@<commit-sha>) by finding the action string in the YAML and
substituting the tag with the corresponding trusted commit SHA from the action's
repository release history; ensure each updated entry still matches the original
action name and that the workflow syntax remains valid.
- Scope pages:write and id-token:write permissions to deploy job only (least privilege) - Use explicit === 'true' comparison for NEXT_STATIC_EXPORT env var - Gate output:'export', basePath, and images config on same isStaticExport flag to prevent conflict with rewrites()
|
Addressed all four CodeRabbit review comments:
|
Automates documentation deployment to GitHub Pages on pushes to
main.Previously, docs had to be deployed manually or weren't deployed at all. This adds a workflow that builds and publishes the docs site automatically, so the published docs stay in sync with the codebase without any manual step.
Summary by CodeRabbit
New Features
Chores