Skip to content

Commit b88983c

Browse files
ci: 更新 Cloudflare API 令牌环境变量名称
- 将 CF_API_TOKEN 重命名为 CF_PAGES_API_TOKEN - 更新了相关文档中的变量名称 - 修改了 GitHub Actions 工作流中的 API 令牌引用
1 parent 9fab3e2 commit b88983c

3 files changed

Lines changed: 26 additions & 20 deletions

File tree

.github/CONFIGURATION_CHECKLIST.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
在使用 GitHub Actions 部署到 Cloudflare Pages 之前,请完成以下配置:
66

7-
### 1. Cloudflare API Token (CF_API_TOKEN)
7+
### 1. Cloudflare API Token (CF_PAGES_API_TOKEN)
88

99
**用途**: 授权 GitHub Actions 访问您的 Cloudflare 账户
1010

@@ -30,7 +30,7 @@
3030
2. 点击 "Settings" (设置)
3131
3. 选择左侧 "Secrets and variables" → "Actions"
3232
4. 点击 "New repository secret"
33-
5. Name: `CF_API_TOKEN`
33+
5. Name: `CF_PAGES_API_TOKEN`
3434
6. Value: 粘贴刚才复制的令牌
3535
7. 点击 "Add secret"
3636

@@ -130,7 +130,7 @@
130130
### 常见问题
131131

132132
1. **部署失败 - 权限错误**
133-
- 检查 `CF_API_TOKEN` 是否有足够权限
133+
- 检查 `CF_PAGES_API_TOKEN` 是否有足够权限
134134
- 确认 Account ID 是否正确
135135

136136
2. **构建失败**

.github/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
### 必需的 Secrets
2626

27-
1. **CF_API_TOKEN**
27+
1. **CF_PAGES_API_TOKEN**
2828
- 用途:Cloudflare API 令牌,用于授权部署操作
2929
- 如何获取:
3030
1. 登录 Cloudflare 控制台

.github/workflows/deploy.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v4
2323

24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v3
26+
with:
27+
version: 9
28+
2429
- name: Setup Node.js
2530
uses: actions/setup-node@v4
2631
with:
2732
node-version: '22'
2833
cache: 'pnpm'
2934

30-
- name: Install pnpm
31-
uses: pnpm/action-setup@v3
32-
with:
33-
version: 9
34-
run_install: false
35-
3635
- name: Get pnpm store directory
3736
shell: bash
3837
run: |
@@ -53,24 +52,31 @@ jobs:
5352
run: pnpm build
5453

5554
- name: Upload artifact
56-
uses: actions/upload-pages-artifact@v3
55+
uses: actions/upload-artifact@v4
5756
with:
57+
name: dist-files
5858
path: ./dist
5959

6060
deploy:
6161
needs: build
6262
runs-on: ubuntu-latest
63-
if: github.ref == 'refs/heads/master'
6463
environment:
65-
name: github-pages
66-
url: ${{ steps.deployment.outputs.page_url }}
64+
name: cloudflare
6765
steps:
66+
- name: Download artifact
67+
uses: actions/download-artifact@v4
68+
with:
69+
name: dist-files
70+
path: ./dist
71+
72+
- name: Check downloaded artifact
73+
run: |
74+
echo "Contents of downloaded artifact:"
75+
ls -la dist/
76+
6877
- name: Deploy to Cloudflare Pages
69-
id: deployment
70-
uses: cloudflare/pages-action@v1.1
78+
uses: cloudflare/wrangler-action@v3
7179
with:
72-
apiToken: ${{ secrets.CF_API_TOKEN }}
80+
apiToken: ${{ secrets.CF_PAGES_API_TOKEN }}
7381
accountId: ${{ secrets.CF_ACCOUNT_ID }}
74-
projectName: ${{ secrets.CF_PROJECT_NAME }}
75-
directory: ./dist
76-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
82+
command: pages deploy ./dist --project-name=${{ secrets.CF_PROJECT_NAME }}

0 commit comments

Comments
 (0)