Repository navigation
68 lines (57 loc) · 2.06 KB
/
Copy pathdeploy.yml
File metadata and controls
68 lines (57 loc) · 2.06 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
name: Deploy to GitHub Pages
# ─────────────────────────────────────────────────────────────
# 首次使用前的唯一一次手动操作(约 30 秒):
# 仓库 Settings → Pages → Build and deployment → Source → 选 "GitHub Actions" → Save
#
# 为什么必须手动:创建 Pages 站点属于「仓库管理」操作,
# 而自动分配的 GITHUB_TOKEN 永远无法管理仓库本身(无论 permissions 怎么写),
# 所以 configure-pages 的 enablement: true 一定会报
# "Resource not accessible by integration"。
# 手动开启一次之后,本工作流就能永久使用默认 Token 正常部署。
# ─────────────────────────────────────────────────────────────
on:
# 推送到 main 分支时自动部署
push:
branches: [main]
# 也可以在 Actions 页面手动触发
workflow_dispatch:
# 只授予最小必要权限
permissions:
contents: read
pages: write
id-token: write
# 同一时间只允许一个部署,但排队执行而不取消,避免半成品上线
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5