File tree Expand file tree Collapse file tree 4 files changed +85
-16
lines changed
Expand file tree Collapse file tree 4 files changed +85
-16
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy Preview
2+
3+ on :
4+ push :
5+ branches-ignore :
6+ - main
7+
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+ name : Deploy Preview
12+ steps :
13+ - uses : actions/checkout@v4
14+
15+ - uses : pnpm/action-setup@v4
16+ with :
17+ version : 9
18+
19+ - name : Setup Node.js
20+ uses : actions/setup-node@v4
21+ with :
22+ node-version : " 22"
23+ cache : " pnpm"
24+
25+ - name : Install dependencies
26+ run : pnpm install
27+
28+ - name : Deploy to Cloudflare Workers with Preview
29+ uses : cloudflare/wrangler-action@v3
30+ with :
31+ apiToken : ${{ secrets.CF_API_TOKEN }}
32+ command : deploy --env preview
33+ env :
34+ CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CF_ACCOUNT_ID }}
Original file line number Diff line number Diff line change @@ -155,17 +155,31 @@ pnpm test
155155
156156## Deployment
157157
158- 1 . Login to Cloudflare
158+ This project uses GitHub Actions to automatically deploy to Cloudflare Workers:
159159
160- ``` bash
161- pnpm dlx wrangler login
162- ```
160+ - Commits to non-main branches create preview deployments
161+ - Commits to main branch deploy to production
163162
164- 2 . Deploy Worker
163+ ### Setup GitHub Secrets
165164
166- ``` bash
167- pnpm deploy
168- ```
165+ To enable automatic deployments, you need to add the following secrets to your GitHub repository:
166+
167+ 1 . Go to your repository on GitHub
168+ 2 . Navigate to Settings > Secrets and variables > Actions
169+ 3 . Add the following secrets:
170+ - ` CF_API_TOKEN ` : Your Cloudflare API token with Workers permissions
171+ - ` CF_ACCOUNT_ID ` : Your Cloudflare account ID
172+
173+ ### How to get Cloudflare credentials
174+
175+ 1 . ** Cloudflare API Token** :
176+ - Go to the [ Cloudflare dashboard] ( https://dash.cloudflare.com/ )
177+ - Navigate to My Profile > API Tokens
178+ - Create a new token with "Edit Workers" permissions
179+
180+ 2 . ** Cloudflare Account ID** :
181+ - Go to the [ Cloudflare dashboard] ( https://dash.cloudflare.com/ )
182+ - Your Account ID is in the URL or on the right sidebar of the Workers page
169183
170184## Tech Stack
171185
Original file line number Diff line number Diff line change @@ -155,17 +155,32 @@ pnpm test
155155
156156## 部署
157157
158- 1 . 登录到 Cloudflare
158+ 本项目使用 GitHub Actions 自动部署到 Cloudflare Workers:
159159
160- ``` bash
161- pnpm dlx wrangler login
162- ```
160+ - 向非主分支提交代码会创建预览部署
161+ - 向主分支提交代码会部署到生产环境
163162
164- 2 . 部署 Worker
163+ ### 设置 GitHub Secrets
165164
166- ``` bash
167- pnpm deploy
168- ```
165+ 要启用自动部署,您需要在 GitHub 仓库中添加以下密钥:
166+
167+ 1 . 前往您的 GitHub 仓库
168+ 2 . 导航到 Settings > Secrets and variables > Actions
169+ 3 . 添加以下密钥:
170+ - ` CF_API_TOKEN ` :您的 Cloudflare API 令牌(需要 Workers 权限)
171+ - ` CF_ACCOUNT_ID ` :您的 Cloudflare 账户 ID
172+
173+ ### 如何获取 Cloudflare 凭据
174+
175+ 1 . ** Cloudflare API 令牌** :
176+
177+ - 前往 [ Cloudflare 控制面板] ( https://dash.cloudflare.com/ )
178+ - 导航到 My Profile > API Tokens
179+ - 创建一个具有"Edit Workers"权限的新令牌
180+
181+ 2 . ** Cloudflare 账户 ID** :
182+ - 前往 [ Cloudflare 控制面板] ( https://dash.cloudflare.com/ )
183+ - 您的账户 ID 在 URL 中或 Workers 页面的右侧栏中
169184
170185## 技术栈
171186
Original file line number Diff line number Diff line change 1+ name = " github-achievements-api"
2+ main = " src/index.ts"
3+ compatibility_date = " 2025-02-27"
4+
5+ [env .preview ]
6+ name = " github-achievements-api-preview"
You can’t perform that action at this time.
0 commit comments