Add Cloudflare Workers deployment method #2205
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds Cloudflare Workers Static Assets as a new deployment method.
Is is a direct API integration, and could replace the to the existing Cloudflare Pages deployment method via Github.
Overview
This implementation uses Cloudflare Workers' static asset hosting capabilities to deploy sites directly to Cloudflare's edge network. It's strongly recommended by Cloudflare that new projects use this rather than CloudFlare Pages.
Key Features & Changes
Core Functionality:
• New
CloudflareWorkersdeployment class (cloudflare-workers.js) with full upload/deployment pipeline• Direct API integration with Cloudflare Workers Static Assets API
• Automatic file hashing and deduplication for efficient uploads
• Batch file upload system using form-data multipart uploads
• Auto-generated worker script that serves static assets with proper routing
Configuration & UI:
• New deployment option in server settings with Cloudflare logo
• Three required configuration fields:
Account ID,API Token, andWorker Name• Secure credential storage via keytar
• Connection testing functionality to validate API access
• Form validation and error handling
Technical Implementation:
• Follows existing Publii deployment patterns and idioms
• Integrated into main deployment system (
deployment.js)• Support for 404s via the existing 404.html in worker configuration
• Auto-trailing-slash HTML handling for clean URLs
• Progress tracking and status reporting during deployment
Setup Requirements:
• Cloudflare account with Workers plan (free is fine)
• API token with Workers edit permissions
• Account ID from Cloudflare dashboard
• Worker name (can be created via one of the Cloudflare onboarding starters, gets overwritten)
• Optional: Custom domain can be later added via Cloudflare Workers Web UI
Refs: #2049 #996 #1174