Skip to content

Commit 230374c

Browse files
authored
Merge branch 'ling-drag0n:main' into main
2 parents e65caa7 + ef6edba commit 230374c

File tree

134 files changed

+5247
-2860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+5247
-2860
lines changed

.github/ISSUE_TEMPLATE/bug__report_EN.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ body:
2121
options:
2222
- Docker
2323
- Cloudflare Worker
24+
- Cloudflare Worker And Pages
2425
validations:
2526
required: true
2627

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ body:
2020
description: 采用的部署方式?
2121
options:
2222
- Docker
23-
- Cloudfare worker
24-
23+
- Cloudflare worker
24+
- Cloudflare Worker And Pages
2525
validations:
2626
required: true
2727

.github/workflows/deploy-backend-cloudflare.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,60 @@
1-
name: Deploy Backend to Cloudflare Workers
1+
name: Deploy Backend CF Workers[Worker后端分离部署]
22

33
on:
44
push:
55
branches: [main, master]
66
paths:
77
- "backend/**"
88
workflow_dispatch:
9+
inputs:
10+
from_panel:
11+
description: "是否由部署控制面板触发 / triggered from deployment control panel"
12+
required: false
13+
default: "false"
914
repository_dispatch:
1015
types: [deploy-button]
1116

1217
jobs:
18+
check-config:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
should_deploy: ${{ steps.check.outputs.should_deploy }}
22+
steps:
23+
- name: 📥 检出代码
24+
uses: actions/checkout@v4
25+
26+
- name: 🔍 检查部署配置
27+
id: check
28+
run: |
29+
# 手动触发时(workflow_dispatch / repository_dispatch),总是部署,忽略自动部署开关
30+
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
31+
echo "should_deploy=true" >> $GITHUB_OUTPUT
32+
echo "✅ 手动触发(repository_dispatch),忽略开关,允许部署"
33+
exit 0
34+
fi
35+
36+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.from_panel }}" != "true" ]]; then
37+
echo "should_deploy=true" >> $GITHUB_OUTPUT
38+
echo "✅ 手动触发(workflow_dispatch),忽略开关,允许部署"
39+
exit 0
40+
fi
41+
42+
# 自动触发(push 或控制面板触发)根据仓库级变量决定是否部署
43+
BACKEND_ENABLED="${{ vars.BACKEND_DEPLOY }}"
44+
# 默认行为:如果仓库变量未设置,视为已开启自动部署(向下兼容旧逻辑)
45+
[ -z "$BACKEND_ENABLED" ] && BACKEND_ENABLED="true"
46+
47+
if [ "$BACKEND_ENABLED" = "true" ]; then
48+
echo "should_deploy=true" >> $GITHUB_OUTPUT
49+
echo "✅ 后端自动部署已开启,允许部署"
50+
else
51+
echo "should_deploy=false" >> $GITHUB_OUTPUT
52+
echo "⏸️ 后端自动部署已关闭,跳过部署"
53+
fi
54+
1355
deploy-backend:
56+
needs: check-config
57+
if: needs.check-config.outputs.should_deploy == 'true'
1458
runs-on: ubuntu-latest
1559
defaults:
1660
run:

.github/workflows/deploy-frontend-cloudflare.yml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy Frontend to Cloudflare Pages
1+
name: Deploy Frontend CF Pages[Pages前端分离部署]
22

33
on:
44
push:
@@ -7,11 +7,55 @@ on:
77
- "frontend/**"
88
- "!frontend/vercel.json"
99
workflow_dispatch:
10+
inputs:
11+
from_panel:
12+
description: "是否由部署控制面板触发 / triggered from deployment control panel"
13+
required: false
14+
default: "false"
1015
repository_dispatch:
1116
types: [deploy-button]
1217

1318
jobs:
19+
check-config:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
should_deploy: ${{ steps.check.outputs.should_deploy }}
23+
steps:
24+
- name: 📥 检出代码
25+
uses: actions/checkout@v4
26+
27+
- name: 🔍 检查部署配置
28+
id: check
29+
run: |
30+
# 手动触发时(workflow_dispatch / repository_dispatch),总是部署,忽略自动部署开关
31+
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
32+
echo "should_deploy=true" >> $GITHUB_OUTPUT
33+
echo "✅ 手动触发(repository_dispatch),忽略开关,允许部署"
34+
exit 0
35+
fi
36+
37+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.from_panel }}" != "true" ]]; then
38+
echo "should_deploy=true" >> $GITHUB_OUTPUT
39+
echo "✅ 手动触发(workflow_dispatch),忽略开关,允许部署"
40+
exit 0
41+
fi
42+
43+
# 自动触发(push 或控制面板触发)根据仓库级变量决定是否部署
44+
FRONTEND_ENABLED="${{ vars.FRONTEND_DEPLOY }}"
45+
# 默认行为:如果仓库变量未设置,视为已开启自动部署(向下兼容旧逻辑)
46+
[ -z "$FRONTEND_ENABLED" ] && FRONTEND_ENABLED="true"
47+
48+
if [ "$FRONTEND_ENABLED" = "true" ]; then
49+
echo "should_deploy=true" >> $GITHUB_OUTPUT
50+
echo "✅ 前端自动部署已开启,允许部署"
51+
else
52+
echo "should_deploy=false" >> $GITHUB_OUTPUT
53+
echo "⏸️ 前端自动部署已关闭,跳过部署"
54+
fi
55+
1456
deploy-frontend-cloudflare:
57+
needs: check-config
58+
if: needs.check-config.outputs.should_deploy == 'true'
1559
runs-on: ubuntu-latest
1660
defaults:
1761
run:
@@ -100,7 +144,17 @@ jobs:
100144
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
101145
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
102146
run: |
103-
npx wrangler pages deploy ./dist --project-name=cloudpaste-frontend --branch production 2>&1 | sed -E 's/https:\/\/[a-zA-Z0-9.-]*\.(workers|pages)\.dev/https:\/\/[REDACTED].\1.dev/g'
147+
COMMIT_MSG=$(cat << 'EOF'
148+
${{ github.event.head_commit.message }}
149+
EOF
150+
)
151+
# 清理非UTF-8字符并限制长度
152+
CLEAN_MSG=$(echo "$COMMIT_MSG" | iconv -f utf-8 -t utf-8 -c | head -c 200)
153+
# 如果消息为空或无效,使用默认消息
154+
if [ -z "$CLEAN_MSG" ]; then
155+
CLEAN_MSG="Deploy from GitHub Actions"
156+
fi
157+
npx wrangler pages deploy ./dist --project-name=cloudpaste-frontend --branch production --commit-message="$CLEAN_MSG" 2>&1 | sed -E 's/https:\/\/[a-zA-Z0-9.-]*\.(workers|pages)\.dev/https:\/\/[REDACTED].\1.dev/g'
104158
105159
- name: Display Success Information
106160
if: steps.check-deploy-button.outputs.is_deploy_button == 'true' && success()

0 commit comments

Comments
 (0)