Skip to content

Conversation

@oscarvz
Copy link
Member

@oscarvz oscarvz commented Nov 4, 2025

Summary

Migrate docs site deployment from static R2 bucket hosting to Cloudflare Workers with on-demand rendering.

Changes

  • Added @astrojs/cloudflare adapter and configured Astro for SSR deployment
  • Installed wrangler and added wrangler.jsonc configuration
  • Updated GitHub Actions workflow to deploy using wrangler deploy instead of R2 sync
  • Enables dynamic page generation, including custom 404 error pages
  • Updated all doc page routes to use trailing slashes for consistent routing

Why

Static R2 hosting doesn't support dynamic pages or custom error handling. By deploying to Workers, we can now serve dynamically generated pages and provide a better user experience with proper 404 handling.

Summary by CodeRabbit

  • Infrastructure & Deployment

    • Migrated deployment infrastructure from AWS to Cloudflare using Wrangler
  • Documentation

    • Standardized all internal documentation links by removing trailing slashes for canonical URL routing
  • Chores

    • Updated dependencies and configuration to support Cloudflare adapter

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Walkthrough

This pull request migrates the deployment infrastructure from GitHub Actions with AWS S3/R2 to Cloudflare Workers using Wrangler. It consolidates separate auto-deploy and manual-deploy workflows into a single push-triggered workflow, updates the Astro configuration to use the Cloudflare adapter, adds Wrangler dependencies, and normalizes internal documentation links by removing trailing slashes.

Changes

Cohort / File(s) Summary
GitHub Actions Workflows
.github/workflows/auto-deploy.yaml, .github/workflows/manual-deploy.yaml
Deleted workflows that triggered Cloudflare R2 deployments via workflow_call and workflow_dispatch patterns.
Main Deployment Workflow
.github/workflows/deploy.yaml
Reworked from event-based workflow_call trigger to push-based trigger on main branch. Replaced AWS S3/R2 sync deployment steps with Cloudflare Wrangler deployment action (v3). Updated checkout action to v5, added node-version matrix (22), and streamlined build sequence.
Astro Configuration
astro.config.ts
Added adapter: cloudflare() to Astro config, replaced trailingSlash: "always" setting. Normalized navigation link URLs throughout config by removing trailing slashes from internal routes.
Dependencies
package.json
Added @astrojs/cloudflare and wrangler to dependencies/devDependencies. Moved typescript from dependencies to devDependencies.
Cloudflare Workers Configuration
wrangler.jsonc
New configuration file for Wrangler with deployment name, worker entry point, compatibility settings, asset bindings, and observability configuration.
Asset Ignore Patterns
public/.assetsignore
New file containing ignore patterns for _worker.js and _routes.json.
Documentation Links Normalization
src/content/docs/index.mdx, src/content/docs/mcp-gateway/.../*, src/content/docs/mcp-lite/.../*, src/content/docs/reference/example.md
Updated all internal navigation links across documentation to remove trailing slashes. Affected 30+ markdown files with consistent pattern of URL path normalization (e.g., /path//path).

Sequence Diagram

sequenceDiagram
    participant GitHub as GitHub (Push to main)
    participant OldWF as Old Workflows
    participant NewWF as New Workflow
    participant Wrangler as Cloudflare Wrangler
    participant CF as Cloudflare Workers

    rect rgb(240, 248, 255)
    Note over OldWF: Previous Approach
    GitHub->>OldWF: Trigger auto-deploy.yaml
    OldWF->>OldWF: workflow_call deploy.yaml
    OldWF->>OldWF: AWS S3/R2 credentials
    OldWF->>OldWF: s3 sync build/
    end

    rect rgb(240, 255, 240)
    Note over NewWF: New Approach
    GitHub->>NewWF: Push to main
    NewWF->>NewWF: Setup Node 22
    NewWF->>NewWF: Install pnpm<br/>(--frozen-lockfile)
    NewWF->>NewWF: pnpm build
    NewWF->>Wrangler: Deploy with wrangler-action
    Wrangler->>CF: Deploy to Workers + Assets
    CF-->>Wrangler: Deployment confirmed
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Deployment workflow changes: Review the reworked .github/workflows/deploy.yaml for correctness of the Cloudflare Wrangler deployment configuration and matrix strategy.
  • Astro adapter migration: Verify that the Cloudflare adapter addition in astro.config.ts is properly configured and all trailing slash removals from config routes are intentional.
  • Wrangler configuration: Validate wrangler.jsonc against Cloudflare Workers requirements, particularly the worker entry point path (./dist/_worker.js/index.js) and asset binding.
  • Package.json changes: Confirm dependency versions and the move of typescript to devDependencies doesn't break the build process.
  • Documentation link changes: While numerous, these are repetitive and low-risk; a spot-check of a few files is sufficient to confirm the pattern.

Poem

🐰 From clouds of AWS, we hop away,
To Cloudflare's bright and verdant bay!
No more R2 buckets in the night,
Wrangler deploys with pure delight.
Trailing slashes trimmed with care,
The docs now dance through cleaner air! ✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Deploy to Cloudflare Workers instead of R2 bucket' accurately and clearly describes the main objective of this changeset, which involves migrating the deployment infrastructure from R2 to Cloudflare Workers.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch deploy-to-workers

Comment @coderabbitai help to get the list of available commands and usage tips.

@oscarvz oscarvz marked this pull request as ready for review November 4, 2025 10:53
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (7)
src/content/docs/mcp-lite/core-concepts/type-safety.md (1)

135-136: Consistent with repository-wide URL normalization.

Link changes align with the broader trailing-slash removal pattern across documentation files in this PR. Routing verification for one file applies to all.

src/content/docs/mcp-lite/features/sessions.md (1)

72-73: Consistent with repository-wide URL normalization.

Link changes align with the broader trailing-slash removal pattern across documentation files in this PR. Routing verification for one file applies to all.

src/content/docs/index.mdx (1)

12-13: Consistent with repository-wide URL normalization.

Link changes align with the broader trailing-slash removal pattern across documentation files in this PR. Routing verification for one file applies to all.

src/content/docs/mcp-lite/advanced/sampling.md (1)

90-91: Consistent with repository-wide URL normalization.

Link changes align with the broader trailing-slash removal pattern across documentation files in this PR. Routing verification for one file applies to all.

src/content/docs/mcp-gateway/core-concepts/activity-logging.md (1)

237-239: Consistent with repository-wide URL normalization.

Link changes align with the broader trailing-slash removal pattern across documentation files in this PR. Routing verification for one file applies to all.

src/content/docs/mcp-gateway/getting-started.md (1)

118-120: Consistent with repository-wide URL normalization.

Link changes align with the broader trailing-slash removal pattern across documentation files in this PR. Routing verification for one file applies to all.

src/content/docs/mcp-gateway/features/terminal-ui.md (1)

307-309: Consistent with repository-wide URL normalization.

Link changes align with the broader trailing-slash removal pattern across documentation files in this PR. Routing verification for one file applies to all.

🧹 Nitpick comments (1)
.github/workflows/deploy.yaml (1)

17-21: Consider adding dependency caching for faster builds.

The workflow doesn't cache pnpm dependencies, which could slow down builds.

Add caching between checkout and install steps:

       - uses: actions/checkout@v5
       - uses: pnpm/action-setup@v4
+      
+      - name: Setup Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: 22
+          cache: 'pnpm'

       - name: Install dependencies
         run: pnpm install --frozen-lockfile
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2e4e8d and 268640c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • .github/workflows/auto-deploy.yaml (0 hunks)
  • .github/workflows/deploy.yaml (1 hunks)
  • .github/workflows/manual-deploy.yaml (0 hunks)
  • astro.config.ts (5 hunks)
  • package.json (1 hunks)
  • public/.assetsignore (1 hunks)
  • src/content/docs/index.mdx (1 hunks)
  • src/content/docs/mcp-gateway/core-concepts/activity-logging.md (1 hunks)
  • src/content/docs/mcp-gateway/core-concepts/interfaces.md (1 hunks)
  • src/content/docs/mcp-gateway/core-concepts/server-management.md (1 hunks)
  • src/content/docs/mcp-gateway/features/cli-options.md (1 hunks)
  • src/content/docs/mcp-gateway/features/storage.md (1 hunks)
  • src/content/docs/mcp-gateway/features/terminal-ui.md (1 hunks)
  • src/content/docs/mcp-gateway/features/web-interface.md (1 hunks)
  • src/content/docs/mcp-gateway/getting-started.md (1 hunks)
  • src/content/docs/mcp-gateway/index.md (1 hunks)
  • src/content/docs/mcp-gateway/troubleshooting.md (1 hunks)
  • src/content/docs/mcp-lite/advanced/elicitation.md (1 hunks)
  • src/content/docs/mcp-lite/advanced/protocol-versions.md (1 hunks)
  • src/content/docs/mcp-lite/advanced/sampling.md (1 hunks)
  • src/content/docs/mcp-lite/core-concepts/prompts.md (1 hunks)
  • src/content/docs/mcp-lite/core-concepts/resources.md (1 hunks)
  • src/content/docs/mcp-lite/core-concepts/tools.md (1 hunks)
  • src/content/docs/mcp-lite/core-concepts/type-safety.md (1 hunks)
  • src/content/docs/mcp-lite/deployment/environments.md (1 hunks)
  • src/content/docs/mcp-lite/deployment/patterns.md (1 hunks)
  • src/content/docs/mcp-lite/examples.md (1 hunks)
  • src/content/docs/mcp-lite/features/adapters.md (1 hunks)
  • src/content/docs/mcp-lite/features/error-handling.md (1 hunks)
  • src/content/docs/mcp-lite/features/middleware.md (1 hunks)
  • src/content/docs/mcp-lite/features/sessions.md (1 hunks)
  • src/content/docs/mcp-lite/getting-started.md (1 hunks)
  • src/content/docs/mcp-lite/index.mdx (1 hunks)
  • src/content/docs/reference/example.md (1 hunks)
  • wrangler.jsonc (1 hunks)
💤 Files with no reviewable changes (2)
  • .github/workflows/manual-deploy.yaml
  • .github/workflows/auto-deploy.yaml
🔇 Additional comments (28)
src/content/docs/mcp-lite/advanced/protocol-versions.md (1)

106-107: Clarify trailing slash handling to align with PR objectives.

There is a contradiction between the PR objectives and the actual code changes:

  • PR objectives state: "updating all doc page routes to use trailing slashes for consistent routing"
  • Actual changes: removing trailing slashes from internal links

The links at lines 106-107 are being updated to remove trailing slashes (/sessions//sessions, /elicitation//elicitation), which is the opposite of what the PR summary describes.

Please clarify:

  1. Should trailing slashes be added or removed for consistent Cloudflare Workers routing?
  2. Is the PR objective description accurate, or were the objectives updated after implementation?
  3. Are there other files in this PR that define the authoritative routing behavior (e.g., astro.config.mjs, route definitions)?

This clarification is important to ensure routing consistency across the entire documentation site.

src/content/docs/mcp-lite/features/error-handling.md (1)

105-106: Verify trailing-slash routing configuration.

These links now point to non-trailing-slash URLs. Ensure that astro.config.ts is configured to handle these routes correctly and that this normalization is applied consistently across the build output.

src/content/docs/mcp-lite/getting-started.md (1)

101-104: Verify trailing-slash routing configuration.

Four Next Steps links now use non-trailing-slash URLs. Ensure that Astro's routing configuration handles these paths correctly and applies this normalization consistently across all pages.

src/content/docs/mcp-lite/deployment/patterns.md (1)

121-123: Next Steps links normalized.

Three links updated to non-trailing-slash URLs. Verify routing configuration handles these paths.

src/content/docs/mcp-gateway/features/cli-options.md (1)

239-241: Next Steps links normalized for MCP-Gateway.

Three links updated to non-trailing-slash URLs, maintaining consistency with MCP-Lite documentation changes.

src/content/docs/mcp-lite/deployment/environments.md (1)

159-160: Next Steps links normalized.

Two links updated to non-trailing-slash URLs.

src/content/docs/mcp-gateway/troubleshooting.md (1)

467-469: Next Steps links normalized.

Three links updated to non-trailing-slash URLs.

src/content/docs/mcp-lite/core-concepts/prompts.md (1)

89-90: Next Steps links normalized.

Two links updated to non-trailing-slash URLs.

package.json (2)

23-26: TypeScript correctly moved to devDependencies.

Moving TypeScript to devDependencies is the right approach since it's a build-time tool. Ensure your build script (astro build) includes TypeScript compilation as needed.


15-26: All dependency versions are compatible; no changes needed.

@astrojs/cloudflare v12.6.10 is compatible with Astro 5.6.1, and wrangler v4.45.3 can be used to deploy Astro 5 sites. TypeScript placement in devDependencies is correct for a build-time dependency.

src/content/docs/mcp-gateway/features/web-interface.md (1)

358-360: Consistent with trailing slash removal pattern across documentation.

Internal links have been updated to remove trailing slashes from paths. Assuming the Astro configuration is set to trailingSlash: 'never', these changes align with the deployment migration to Cloudflare Workers. Link syntax and formatting are correct.

Verify that the astro.config.ts is configured with trailingSlash: 'never' or equivalent setting to ensure these slash-less paths are properly routed in the Cloudflare Workers environment.

src/content/docs/mcp-lite/features/middleware.md (1)

95-96: Links normalized to slash-less paths.

Trailing slashes removed from internal navigation links. Consistent with the repository-wide documentation URL normalization.

src/content/docs/mcp-gateway/core-concepts/interfaces.md (1)

252-254: Next Steps links updated consistently.

All trailing slashes removed from internal documentation paths in the Next Steps section.

src/content/docs/mcp-lite/core-concepts/resources.md (1)

88-89: Internal link normalization applied.

Next Steps links updated to slash-less paths consistent with the trailing slash configuration.

src/content/docs/mcp-lite/advanced/elicitation.md (1)

75-76: Trailing slashes removed from Next Steps links.

Consistent normalization of internal navigation paths.

src/content/docs/mcp-lite/examples.md (1)

133-134: Next Steps links normalized.

Trailing slashes removed from internal documentation paths.

src/content/docs/mcp-lite/features/adapters.md (1)

116-117: Trailing slash normalization in Next Steps section.

Internal documentation links updated to remove trailing slashes.

src/content/docs/mcp-gateway/core-concepts/server-management.md (1)

178-180: No routing issues identified — links are already slash-less and consistent with site configuration.

The internal navigation links in lines 178-180 are already slash-less and align with the existing sidebar configuration in astro.config.ts. Astro v5 with the Cloudflare adapter handles slash-less routes correctly when trailingSlash is configured as 'never' or left to the default 'ignore' behavior, which applies 301/308 redirects from slash URLs when needed. The Starlight-rendered documentation pages will work without issue with this link format.

src/content/docs/mcp-lite/core-concepts/tools.md (1)

168-170: Link normalization looks correct.

The removal of trailing slashes aligns with the Astro configuration changes and Cloudflare adapter usage. However, note that the PR summary states "updating all doc page routes to use trailing slashes" when the actual change is removing them. This inconsistency should be corrected in the PR description.

src/content/docs/mcp-gateway/index.md (1)

94-96: Link normalization is consistent.

These changes align with the project-wide URL normalization to slash-less routes.

src/content/docs/mcp-gateway/features/storage.md (1)

368-370: LGTM!

Link updates are consistent with the routing changes.

src/content/docs/mcp-lite/index.mdx (1)

89-99: LGTM!

All link updates follow the slash-less routing convention.

astro.config.ts (2)

58-169: Extensive link normalization completed successfully.

All sidebar links have been updated to use slash-less routes, ensuring consistency across the documentation navigation.


1-6: The review concern is incorrect for this codebase.

This is a pure static documentation site powered by Starlight with no dynamic routes, API endpoints, or server-side logic. The default output: "static" mode is appropriate and intentional. The Cloudflare adapter's default advanced mode handles static sites correctly. No explicit output: "server" configuration is needed.

Likely an incorrect or invalid review comment.

public/.assetsignore (1)

1-2: Appropriate ignore patterns for Cloudflare Workers artifacts.

These patterns correctly exclude the worker script and routing configuration from being treated as static assets.

wrangler.jsonc (2)

5-12: Configuration looks appropriate for the deployment target.

The compatibility flags and observability settings are well-suited for a documentation site deployment on Cloudflare Workers.


3-3: Entry point path is correct.

The path ./dist/_worker.js/index.js is the standard output structure for the Astro Cloudflare adapter. The dist/_worker.js/index.js is the Module Worker entry that Cloudflare Pages uses in advanced mode and should be configured as the Wrangler "main" target. The nested structure is intentional and properly configured in your wrangler.jsonc.

.github/workflows/deploy.yaml (1)

26-31: Deployment configuration is secure and correct.

The Wrangler action is properly configured with required secrets, and the workflow will automatically deploy on pushes to main.

@oscarvz oscarvz merged commit fc6dccb into main Nov 4, 2025
2 checks passed
@oscarvz oscarvz deleted the deploy-to-workers branch November 4, 2025 11:20
@coderabbitai coderabbitai bot mentioned this pull request Dec 4, 2025
Merged
@coderabbitai coderabbitai bot mentioned this pull request Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants