-
Notifications
You must be signed in to change notification settings - Fork 3
123 lines (103 loc) · 3.78 KB
/
deploy-flasher.yml
File metadata and controls
123 lines (103 loc) · 3.78 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# GitHub Actions workflow for deploying the web flasher to GitHub Pages
# 用于将网页烧录器部署到 GitHub Pages 的工作流
#
# This workflow:
# 1. Waits for build-firmware workflow to complete
# 2. Downloads firmware artifacts
# 3. Deploys to GitHub Pages
#
# 此工作流:
# 1. 等待 build-firmware 工作流完成
# 2. 下载固件 artifacts
# 3. 部署到 GitHub Pages
name: Deploy Web Flasher
on:
# Trigger after build-firmware workflow completes | 在 build-firmware 工作流完成后触发
workflow_run:
workflows: ["Build Firmware"]
types:
- completed
branches: [main, master]
# Also trigger on docs/flasher changes (no firmware rebuild needed)
# 在 docs/flasher 更改时也触发(无需重新构建固件)
push:
branches: [main, master]
paths:
- 'docs/flasher/**'
- '.github/workflows/deploy-flasher.yml'
workflow_dispatch: # Allow manual trigger | 允许手动触发
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Deploy to GitHub Pages | 部署到 GitHub Pages
deploy:
# Only run if triggered by successful build or push/manual trigger
# 仅在构建成功触发或 push/手动触发时运行
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download firmware artifacts from workflow_run
if: ${{ github.event_name == 'workflow_run' }}
uses: dawidd6/action-download-artifact@v3
with:
workflow: build-firmware.yml
run_id: ${{ github.event.workflow_run.id }}
name: all-firmware
path: firmware-download/
- name: Download firmware artifacts (manual/push trigger)
if: ${{ github.event_name != 'workflow_run' }}
uses: dawidd6/action-download-artifact@v3
with:
workflow: build-firmware.yml
branch: main
name: all-firmware
path: firmware-download/
continue-on-error: true # May not exist if only docs changed | 如果只是 docs 更改可能不存在
- name: Prepare deployment directory
run: |
# Create deployment directory | 创建部署目录
mkdir -p deploy/flasher/firmware
# Copy flasher HTML and assets | 复制烧录器 HTML 和资源
cp docs/flasher/index.html deploy/flasher/
cp docs/flasher/README.md deploy/flasher/
cp docs/flasher/firmware-config.yml deploy/flasher/
# Copy firmware binaries | 复制固件二进制文件
if [ -d "firmware-download" ]; then
cp -r firmware-download/* deploy/flasher/firmware/
fi
# Create index for root | 为根目录创建索引
cat > deploy/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=flasher/">
<title>Redirecting...</title>
</head>
<body>
<p>Redirecting to <a href="flasher/">Web Flasher</a>...</p>
</body>
</html>
EOF
echo "Deployment directory structure:"
find deploy -type f
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: deploy/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4