-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhugo-github-linux-build-deploy.yml
More file actions
151 lines (134 loc) · 4.41 KB
/
hugo-github-linux-build-deploy.yml
File metadata and controls
151 lines (134 loc) · 4.41 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: "hugo-github-linux-build-deploy"
on:
push:
branches:
- hugo-blog
paths-ignore:
- .github/workflows/pages-deploy.yml
- .gitignore
- README.md
- LICENSE
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build-hugo-blog:
runs-on: ["self-hosted", "zp-nc10"]
environment:
name: github-pages
steps:
# - name: Auto Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# submodules: true
- name: 手动Checkout
env:
token: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ -e ".git" ]]; then
echo "目录已存在,直接更新"
git checkout hugo-blog
git pull
git log -n2
else
echo "目录不存在,开始克隆"
git clone https://github.com/linjonh/TechBlog.git .
git checkout hugo-blog
fi
pwd && cd themes
if [[ -e "loveIt/.git" ]]; then
echo "目录已存在,直接更新"
cd loveIt && git pull
git log -n2 && cd ..
else
echo "目录不存在,开始克隆"
git clone https://github.com/linjonh/hugo-theme-loveIt.git loveIt
fi
pwd && cd .. && pwd
git config --global --add safe.directory $(pwd)
git config --global --add safe.directory $(pwd)/themes/loveIt
git status
#uses: actions/cache@v3
#with:
#path: |
#resources
#public
#key: ${{ runner.os }}-hugo-${{ github.sha }}
#restore-keys: |
#${{ runner.os }}-hugo-
#- name: Cache Hugo Resources
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
# - name: 安装 Hugo
# uses: peaceiris/actions-hugo@v3
# with:
# hugo-version: "0.145.0" # 也可以指定具体版本,如 '0.123.4'
# extended: true # 是否安装扩展版(支持 SCSS/SASS)
- name: 检查是否已安装 Hugo
id: hugo_check
run: |
if command -v hugo > /dev/null; then
echo "found=true" >> $GITHUB_OUTPUT
else
echo "found=false" >> $GITHUB_OUTPUT
fi
- name: 安装 Hugo
if: steps.hugo_check.outputs.found == 'false'
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "0.145.0"
extended: true
- name: show veresion
run: hugo version
- name: Build site
# --gc:启用垃圾回收(清理无用资源)。
# --minify:压缩 HTML、CSS 和 JS,提高构建效率。
# --templateMetrics:输出模板渲染耗时。
# --templateMetricsHints:提供优化建议,帮你找出构建瓶颈。
run: |
echo "开始构建"
echo "pwd && GOMAXPROCS=$(nproc) HUGO_ENVIRONMENT=production hugo --gc --minify --templateMetrics --templateMetricsHints"
pwd && GOMAXPROCS=$(nproc) HUGO_ENVIRONMENT=production hugo --gc --minify --templateMetrics --templateMetricsHints
# #上传到github pages
# - name: Upload site artifact
# uses: actions/upload-pages-artifact@v3
# with:
# path: public
# node js 上传搜索数据
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
#上传到firebase hosting
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_DEEPSEEKSBLOG }}
channelId: live
projectId: deepseeksblog
- name: Install dependencies
run: npm install
- name: Run script
env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_WRITE_KEY: ${{ secrets.ALGOLIA_WRITE_KEY }}
run: npm run upload
# deploy:
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# runs-on: ["self-hosted", "zp-nc10"]
# needs: build-hugo-blog
# steps:
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4