internal-comms
Write internal communications following company formats, including status reports, leadership updates, and newsletters.
ANanthropics/skills203k3,333 new stars in the last 7 days
Cloudflare 部署方法论,使用 wrangler CLI 部署 Cloudflare Pages(前端/静态站点)和 Workers(Serverless 边缘函数)
npm i -g wranglernpx wrangler login(需要用户交互完成授权)npx wrangler whoami| 项目类型 | 部署模式 | 命令 |
|---|---|---|
| 前端应用 / SPA | Cloudflare Pages | wrangler pages deploy |
| 静态站点 | Cloudflare Pages | wrangler pages deploy |
| Serverless API / 边缘函数 | Workers | wrangler deploy |
| Next.js SSR | Pages (Next adapter) | wrangler pages deploy |
npm run build
# 产物目录通常为 dist/、build/ 或 .next/
# 部署静态产物到 Cloudflare Pages
npx wrangler pages deploy dist --project-name=my-app
首次部署输出示例:
✨ Compiled Worker successfully
🌍 Uploading... (20.4 MB)
✨ Deployment complete! Take a peek over at https://my-app.pages.dev
Pages 项目可以使用 wrangler.toml 或命令行参数管理配置:
name = "my-app"
compatibility_date = "2024-01-01"
pages_build_output_dir = "dist"
[env.production]
name = "my-app"
[env.staging]
name = "my-app-staging"
# 设置环境变量(Pages)
npx wrangler pages secret put DATABASE_URL
# 列出 secrets
npx wrangler pages secret list
# 删除 secret
npx wrangler pages secret delete DATABASE_URL
# 绑定自定义域名到 Pages 项目
npx wrangler pages domain add example.com --project-name=my-app
name = "my-worker"
main = "src/index.ts"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]
# 路由绑定
routes = [
{ pattern = "api.example.com/*", zone_name = "example.com" }
]
# KV 命名空间绑定
[[kv_namespaces]]
binding = "MY_KV"
id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# R2 存储桶绑定
[[r2_buckets]]
binding = "MY_BUCKET"
bucket_name = "my-bucket"
# D1 数据库绑定
[[d1_databases]]
binding = "DB"
database_name = "my-db"
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# 部署(首次会自动创建)
npx wrangler deploy
# 部署到特定环境
npx wrangler deploy --env staging
# 本地预览
npx wrangler dev
# 添加 secret
npx wrangler secret put API_KEY
# 列出 secrets
npx wrangler secret list
# 删除 secret
npx wrangler secret delete API_KEY
# 创建 KV 命名空间
npx wrangler kv namespace create MY_KV
# 写入 KV 数据
npx wrangler kv key put --namespace-id=<ID> mykey myvalue
# 读取 KV 数据
npx wrangler kv key get --namespace-id=<ID> mykey
# 创建 R2 存储桶
npx wrangler r2 bucket create my-bucket
# 上传文件到 R2
npx wrangler r2 object put my-bucket/file.txt --file=./file.txt
name: Deploy to Cloudflare Pages
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: my-app
directory: dist
name: Deploy Worker
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
- name: Deploy
run: npx wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
需要的 Secrets:
CLOUDFLARE_API_TOKEN:Cloudflare API Token(My Profile → API Tokens → Create Token,选 "Edit Cloudflare Workers" 模板)CLOUDFLARE_ACCOUNT_ID:账户 ID(Workers 页面右侧栏可获取)| 项目类型 | 配置要点 | 产物目录 |
|---|---|---|
| Vite (React/Vue) | pages_build_output_dir = "dist" | dist |
| Next.js 静态导出 | output: 'export' in next.config | out |
| Astro | 自动检测 | dist |
| SvelteKit | 使用 adapter-cloudflare | build |
| Workers (Hono/itty-router) | main = "src/index.ts" | - |
wrangler.toml 配置正确(项目名、产物目录、绑定)wrangler whoami)*.pages.dev 或自定义域名)Write internal communications following company formats, including status reports, leadership updates, and newsletters.
ANanthropics/skills203k3,333 new stars in the last 7 days
GAgarrytan/gstack143k636 new stars in the last 7 days
ADaddyosmani/agent-skills122k1,627 new stars in the last 7 days
A pre-launch checklist covering monitoring, staged rollouts and rollback plans.
ADaddyosmani/agent-skills122k1,627 new stars in the last 7 days
PApaperclipai/paperclip119k2,120 new stars in the last 7 days
RUruvnet/RuView106k693 new stars in the last 7 days