-
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (78 loc) · 2.88 KB
/
Copy pathdeploy.yml
File metadata and controls
95 lines (78 loc) · 2.88 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
name: Deploy Next.js site to Pages
on:
# 改代码(非文章/说说)时直接部署,但不会发 Bark 通知
push:
branches: ["main"]
paths-ignore:
- 'XHBlogs/moments/**'
- 'XHBlogs/posts/**'
- 'XHBlogs/chatters/**'
- 'XHBlogs/public/moments/**'
- 'XHBlogs/public/posts/**'
- 'XHBlogs/public/chatters/**'
# 文章/说说/杂谈推送后:等 auto-date 跑完再部署,且会精准发送通知
workflow_run:
workflows: ["Auto Fix Frontmatter & Fill Images"]
types:
- completed
# 手动触发仍然保留
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
deploy:
# workflow_run 时:只有成功才部署;手动/普通 push 照常跑
if: >
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# workflow_run 触发时,拉最新 main(含 auto-date 刚推的提交)
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup Pages
uses: actions/configure-pages@v5
with:
# 显式设为空,防止自动注入 /blog 子路径
static_site_generator: next
- name: Install dependencies
working-directory: ./XHBlogs
run: npm ci || npm install
- name: Build site
working-directory: ./XHBlogs
env:
# 强制设置环境变量为空
NEXT_PUBLIC_BASE_PATH: ""
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./XHBlogs/out
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# ==============================
# Bark 通知(仅限 workflow_run 或手动触发才推送)
# ==============================
- name: Bark 推送 - 发布成功
if: success() && (github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch')
run: |
curl "${{ secrets.BARK_URL }}动态更新成功?title=个人博客&sound=shake&icon=https://wxidqlvk.github.io/moments/favicon/2026/08/23/1.webp"
- name: Bark 推送 - 发布失败
if: failure() && !cancelled() && (github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch')
run: |
curl "${{ secrets.BARK_URL }}网站构建失败?title=个人博客&sound=shake&icon=https://wxidqlvk.github.io/moments/favicon/2026/08/23/1.webp"