switch from github action to cloudflare native worker deployment
This commit is contained in:
parent
ae90f4943d
commit
365ad2f59f
|
|
@ -0,0 +1,101 @@
|
|||
# Cloudflare Worker Native Deployment Setup
|
||||
|
||||
This guide explains how to set up Cloudflare's native Git integration for automatic worker deployments.
|
||||
|
||||
## Quick Setup Steps
|
||||
|
||||
### 1. Enable Git Integration in Cloudflare Dashboard
|
||||
|
||||
1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com/)
|
||||
2. Navigate to **Workers & Pages** → **jeffemmett-canvas**
|
||||
3. Go to **Settings** → **Builds & Deployments**
|
||||
4. Click **"Connect to Git"** or **"Set up Git integration"**
|
||||
5. Authorize Cloudflare to access your GitHub repository
|
||||
6. Select your repository: `Jeff-Emmett/canvas-website`
|
||||
7. Configure:
|
||||
- **Production branch**: `main`
|
||||
- **Build command**: Leave empty (wrangler automatically detects and builds from `wrangler.toml`)
|
||||
- **Root directory**: `/` (or leave empty)
|
||||
|
||||
### 2. Configure Build Settings
|
||||
|
||||
Cloudflare will automatically:
|
||||
- Detect `wrangler.toml` in the root directory
|
||||
- Build and deploy the worker on every push to `main`
|
||||
- Show build status in GitHub (commit statuses, PR comments)
|
||||
|
||||
### 3. Environment Variables
|
||||
|
||||
Set environment variables in Cloudflare Dashboard:
|
||||
1. Go to **Workers & Pages** → **jeffemmett-canvas** → **Settings** → **Variables**
|
||||
2. Add any required environment variables
|
||||
3. These are separate from `wrangler.toml` (which should only have non-sensitive config)
|
||||
|
||||
### 4. Verify Deployment
|
||||
|
||||
After setup:
|
||||
1. Push a commit to `main` branch
|
||||
2. Check Cloudflare Dashboard → **Workers & Pages** → **jeffemmett-canvas** → **Deployments**
|
||||
3. You should see a new deployment triggered by the Git push
|
||||
4. Check GitHub commit status - you should see Cloudflare build status
|
||||
|
||||
## How It Works
|
||||
|
||||
- **On push to `main`**: Automatically deploys to production using `wrangler.toml`
|
||||
- **On pull request**: Can optionally deploy to preview environment
|
||||
- **Build status**: Appears in GitHub as commit status and PR comments
|
||||
- **Deployments**: All visible in Cloudflare Dashboard
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
### Production (main branch)
|
||||
- Uses `wrangler.toml` from root directory
|
||||
- Worker name: `jeffemmett-canvas`
|
||||
- R2 buckets: `jeffemmett-canvas`, `board-backups`
|
||||
|
||||
### Development/Preview
|
||||
- For dev environment, you can:
|
||||
- Use a separate worker with `wrangler.dev.toml` (requires manual deployment)
|
||||
- Or configure preview deployments in Cloudflare dashboard
|
||||
- Or use the deprecated GitHub Action (see `.github/workflows/deploy-worker.yml.disabled`)
|
||||
|
||||
## Manual Deployment (if needed)
|
||||
|
||||
If you need to deploy manually:
|
||||
|
||||
```bash
|
||||
# Production
|
||||
npm run deploy:worker
|
||||
# or
|
||||
wrangler deploy
|
||||
|
||||
# Development
|
||||
npm run deploy:worker:dev
|
||||
# or
|
||||
wrangler deploy --config wrangler.dev.toml
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Build fails
|
||||
- Check Cloudflare Dashboard → Deployments → View logs
|
||||
- Ensure `wrangler.toml` is in root directory
|
||||
- Verify all required environment variables are set in Cloudflare dashboard
|
||||
|
||||
### Not deploying automatically
|
||||
- Verify Git integration is connected in Cloudflare dashboard
|
||||
- Check that "Automatically deploy from Git" is enabled
|
||||
- Ensure you're pushing to the configured branch (`main`)
|
||||
|
||||
### Need to revert to GitHub Actions
|
||||
- Rename `.github/workflows/deploy-worker.yml.disabled` back to `deploy-worker.yml`
|
||||
- Disable Git integration in Cloudflare dashboard
|
||||
|
||||
## Benefits of Native Deployment
|
||||
|
||||
✅ **Simpler**: No workflow files to maintain
|
||||
✅ **Integrated**: Build status in GitHub
|
||||
✅ **Automatic**: Resource provisioning (KV, R2, Durable Objects)
|
||||
✅ **Free**: No GitHub Actions minutes usage
|
||||
✅ **Visible**: All deployments in Cloudflare dashboard
|
||||
|
||||
|
|
@ -18,33 +18,35 @@ See `CLOUDFLARE_PAGES_MIGRATION.md` for detailed migration guide.
|
|||
|
||||
## Worker Deployment Strategy
|
||||
|
||||
**Recommendation: Use GitHub Actions only** to avoid conflicts and duplication.
|
||||
**Using Cloudflare's Native Git Integration** for automatic deployments.
|
||||
|
||||
### Current Setup
|
||||
- ✅ **GitHub Actions**: Deploys worker on push to `main` branch
|
||||
- ❌ **Cloudflare Workers Builds**: Also deploying (causing conflicts)
|
||||
- ✅ **Cloudflare Workers Builds**: Automatic deployment on push to `main` branch
|
||||
- ✅ **Build Status**: Integrated with GitHub (commit statuses, PR comments)
|
||||
- ✅ **Environment Support**: Production and preview environments
|
||||
|
||||
### How to Disable Cloudflare Workers Builds
|
||||
### How to Configure Cloudflare Native Deployment
|
||||
|
||||
1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com/)
|
||||
2. Navigate to **Workers & Pages** → **jeffemmett-canvas**
|
||||
3. Go to **Settings** → **Builds & Deployments**
|
||||
4. **Disable** "Automatically deploy from Git" or remove the Git integration
|
||||
5. Alternatively, go to **Settings** → **Integrations** and disconnect GitHub if connected
|
||||
4. Ensure **"Automatically deploy from Git"** is enabled
|
||||
5. Configure build settings:
|
||||
- **Build command**: Leave empty (wrangler handles this automatically)
|
||||
- **Root directory**: `/` (or leave empty)
|
||||
- **Environment variables**: Set in Cloudflare dashboard (not in wrangler.toml)
|
||||
|
||||
### Why Use GitHub Actions?
|
||||
### Why Use Cloudflare Native Deployment?
|
||||
|
||||
**Advantages:**
|
||||
- ✅ Single source of truth for deployments
|
||||
- ✅ Better control over deployment process
|
||||
- ✅ Can add tests, checks, and conditional deployments
|
||||
- ✅ Version tracking in GitHub
|
||||
- ✅ No conflicts between two deployment systems
|
||||
- ✅ Simpler setup (no workflow files to maintain)
|
||||
- ✅ Integrated with Cloudflare dashboard
|
||||
- ✅ Automatic resource provisioning (KV, R2, Durable Objects)
|
||||
- ✅ Build status in GitHub (commit statuses, PR comments)
|
||||
- ✅ No GitHub Actions minutes usage
|
||||
- ✅ Less moving parts, easier to debug
|
||||
|
||||
**Cloudflare Workers Builds:**
|
||||
- ❌ Can conflict with GitHub Actions
|
||||
- ❌ Less control over the process
|
||||
- ❌ Harder to debug when issues occur
|
||||
**Note:** The GitHub Action workflow has been deprecated (see `.github/workflows/deploy-worker.yml.disabled`) but kept as backup.
|
||||
|
||||
### Migration Fix
|
||||
|
||||
|
|
|
|||
|
|
@ -9,32 +9,29 @@
|
|||
- **Configuration**: Set in Cloudflare Pages dashboard
|
||||
- **Environment Variables**: Set in Cloudflare Pages dashboard (VITE_* variables)
|
||||
|
||||
### ✅ Worker: GitHub Actions
|
||||
- **Production**: Deploys on push to `main` branch → uses `wrangler.toml`
|
||||
- **Dev**: Deploys on push to `automerge/**` branches → uses `wrangler.dev.toml`
|
||||
- **Manual**: Can trigger via GitHub Actions UI with environment selection
|
||||
### ✅ Worker: Cloudflare Native Git Integration
|
||||
- **Production**: Automatic deployment on push to `main` branch → uses `wrangler.toml`
|
||||
- **Preview**: Automatic deployment for pull requests → uses `wrangler.toml` (or can be configured for dev)
|
||||
- **Build Status**: Integrated with GitHub (commit statuses, PR comments)
|
||||
- **Configuration**: Managed in Cloudflare Dashboard → Settings → Builds & Deployments
|
||||
|
||||
### ❌ Vercel: Can be disabled
|
||||
- Frontend is now on Cloudflare Pages
|
||||
- Worker was never on Vercel
|
||||
- You can safely disconnect/delete the Vercel project
|
||||
|
||||
## Why GitHub Actions for Workers?
|
||||
## Why Cloudflare Native Deployment?
|
||||
|
||||
**GitHub Actions is better than Cloudflare's automatic worker deployments because:**
|
||||
**Cloudflare's native Git integration provides:**
|
||||
|
||||
1. ✅ **More Control**: You can add tests, checks, conditional logic
|
||||
2. ✅ **Better Branching**: Different configs for dev vs prod
|
||||
3. ✅ **Manual Triggers**: Deploy specific environments on demand
|
||||
4. ✅ **No Conflicts**: Single source of truth (no competing deployments)
|
||||
5. ✅ **Version Tracking**: All deployments tracked in GitHub
|
||||
6. ✅ **Flexibility**: Can add deployment gates, notifications, etc.
|
||||
1. ✅ **Simplicity**: No workflow files to maintain, automatic setup
|
||||
2. ✅ **Integration**: Build status directly in GitHub (commit statuses, PR comments)
|
||||
3. ✅ **Resource Provisioning**: Automatically provisions KV, R2, Durable Objects
|
||||
4. ✅ **Environment Support**: Production and preview environments
|
||||
5. ✅ **Dashboard Integration**: All deployments visible in Cloudflare dashboard
|
||||
6. ✅ **No GitHub Actions Minutes**: Free deployment, no usage limits
|
||||
|
||||
**Cloudflare's automatic worker deployments:**
|
||||
- ❌ Less control over the process
|
||||
- ❌ Can conflict with GitHub Actions
|
||||
- ❌ Harder to debug when issues occur
|
||||
- ❌ Limited branching/environment support
|
||||
**Note:** GitHub Actions workflow has been deprecated (see `.github/workflows/deploy-worker.yml.disabled`) but kept as backup if needed.
|
||||
|
||||
## Environment Switching
|
||||
|
||||
|
|
@ -70,10 +67,10 @@ Set environment variables in Cloudflare Pages dashboard:
|
|||
2. Create PR → Auto-deploys to preview environment
|
||||
3. Environment variables set in Cloudflare dashboard
|
||||
|
||||
### Worker (GitHub Actions)
|
||||
### Worker (Cloudflare Native)
|
||||
1. **Production**: Push to `main` → Auto-deploys to production worker
|
||||
2. **Dev**: Push to `automerge/**` branch → Auto-deploys to dev worker
|
||||
3. **Manual**: Go to Actions → "Deploy Worker" → Run workflow → Choose environment
|
||||
2. **Preview**: Create PR → Auto-deploys to preview environment (optional)
|
||||
3. **Manual**: Deploy via `wrangler deploy` command or Cloudflare dashboard
|
||||
|
||||
## Testing Both Environments
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue