-
Notifications
You must be signed in to change notification settings - Fork 58
91 lines (84 loc) · 2.83 KB
/
Copy pathdeploy-cloudflare.yml
File metadata and controls
91 lines (84 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Cloudflare Deploy
# ⚠️ 状态:待测试(尚未端到端验证)
# 已知问题:
# - Windows 用户反馈本地直跑脚本卡在「应用远程数据库迁移」(v2.3.0 已通过 shell:true 修复)
# - CI 触发的端到端流程仍待主人验收
# 推荐部署姿势:本机 `npm run deploy:cloudflare`(详见 README)
on:
workflow_dispatch:
inputs:
branch:
description: 部署到哪个 Pages 分支
required: true
default: main
type: choice
options:
- main
- dev
skip_migrate:
description: 跳过远程数据库迁移
required: true
default: false
type: boolean
skip_server:
description: 跳过 Workers 部署
required: true
default: false
type: boolean
skip_client:
description: 跳过 Pages 前端部署
required: true
default: false
type: boolean
api_base:
description: 手动指定 API_BASE(可留空自动探测)
required: false
type: string
push:
branches:
- main
paths:
- client/**
- server/**
- scripts/deploy-cloudflare.mjs
- package.json
- package-lock.json
- .github/workflows/deploy-cloudflare.yml
concurrency:
group: cloudflare-deploy-${{ github.ref_name }}
cancel-in-progress: false
jobs:
deploy:
name: Deploy Monolith to Cloudflare
runs-on: ubuntu-latest
permissions:
contents: read
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
MONOLITH_API_BASE: ${{ github.event.inputs.api_base || '' }}
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Deploy via scripted pipeline
run: |
args=(--pages-project monolith-client --branch "${TARGET_BRANCH}")
if [ "${SKIP_MIGRATE}" = "true" ]; then args+=(--skip-migrate); fi
if [ "${SKIP_SERVER}" = "true" ]; then args+=(--skip-server); fi
if [ "${SKIP_CLIENT}" = "true" ]; then args+=(--skip-client); fi
if [ -n "${MONOLITH_API_BASE}" ]; then args+=(--api-base "${MONOLITH_API_BASE}"); fi
npm run deploy:cloudflare -- "${args[@]}"
env:
TARGET_BRANCH: ${{ github.event.inputs.branch || 'main' }}
SKIP_MIGRATE: ${{ github.event.inputs.skip_migrate || 'false' }}
SKIP_SERVER: ${{ github.event.inputs.skip_server || 'false' }}
SKIP_CLIENT: ${{ github.event.inputs.skip_client || 'false' }}