Skip to content

Commit b8ac4f2

Browse files
committed
250829
1 parent bf57b9b commit b8ac4f2

File tree

2 files changed

+19
-44
lines changed

2 files changed

+19
-44
lines changed

.github/workflows/hugo.yaml

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
1-
# Sample workflow for building and deploying a Hugo site to GitHub Pages
21
name: Deploy Hugo site to gh-pages branch
32

43
on:
5-
# Runs on pushes targeting the default branch
64
push:
75
branches:
8-
- dev # 或者您希望触发部署的分支,例如 main 或 master
6+
- dev
97

10-
# Allows you to run this workflow manually from the Actions tab
118
workflow_dispatch:
129

13-
# Sets permissions of the GITHUB_TOKEN to allow deployment
1410
permissions:
15-
contents: write # 需要写入权限来推送分支
16-
pages: write # 如果您仍然使用GitHub Pages服务(尽管是推送到gh-pages),保留此权限
17-
id-token: write # 如果您使用OIDC,保留此权限
11+
contents: write
12+
pages: write
13+
id-token: write
1814

19-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
20-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2115
concurrency:
2216
group: "pages"
2317
cancel-in-progress: false
2418

25-
# Default to bash
2619
defaults:
2720
run:
2821
shell: bash
2922

3023
jobs:
31-
# Build job
3224
build:
3325
runs-on: ubuntu-latest
3426
env:
35-
DART_SASS_VERSION: 1.89.2
36-
HUGO_VERSION: 0.148.2
27+
DART_SASS_VERSION: 1.91.0
28+
HUGO_VERSION: 0.149.0
3729
HUGO_ENVIRONMENT: production
3830
TZ: America/Los_Angeles
3931
steps:
@@ -52,10 +44,6 @@ jobs:
5244
with:
5345
submodules: recursive
5446
fetch-depth: 0
55-
# 如果您不使用actions/configure-pages和actions/deploy-pages,则不需要此步骤
56-
# - name: Setup Pages
57-
# id: pages
58-
# uses: actions/configure-pages@v5
5947
- name: Install Node.js dependencies
6048
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
6149
- name: Cache Restore
@@ -70,11 +58,6 @@ jobs:
7058
run: git config core.quotepath false
7159
- name: Build with Hugo
7260
run: |
73-
# 注意:如果您不使用actions/configure-pages,则baseURL可能需要硬编码或从其他地方获取
74-
# 如果您的GitHub Pages URL是 username.github.io/repo-name/
75-
# 则 baseURL 应该是 /repo-name/
76-
# 如果是 username.github.io/
77-
# 则 baseURL 应该是 /
7861
hugo \
7962
--gc \
8063
--minify \
@@ -87,54 +70,46 @@ jobs:
8770
path: |
8871
${{ runner.temp }}/hugo_cache
8972
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
90-
# 添加 Pagefind 安装和执行步骤
9173
- name: Install Pagefind and build search index
9274
run: |
9375
npm install -g pagefind # 安装 Pagefind CLI
9476
pagefind --site public # 在 public 目录上运行 Pagefind
95-
# 添加此步骤以将构建的站点内容作为 artifact 上传
9677
- name: Upload public directory as artifact
9778
uses: actions/upload-artifact@v4
9879
with:
99-
name: hugo-site-public # artifact 的名称
100-
path: ./public # 要上传的目录
80+
name: hugo-site-public
81+
path: ./public
10182

102-
# Deployment job
10383
deploy:
10484
environment:
105-
name: github-pages # 仍然可以使用此环境,但实际部署方式不同
106-
url: ${{ steps.deployment.outputs.page_url }} # 此URL将由peaceiris/actions-gh-pages提供
85+
name: github-pages
86+
url: ${{ steps.deployment.outputs.page_url }}
10787
runs-on: ubuntu-latest
108-
needs: build # 确保在构建完成后运行
88+
needs: build
10989
steps:
11090
- name: Checkout
11191
uses: actions/checkout@v4
11292
with:
11393
submodules: recursive
114-
fetch-depth: 0 # 确保获取完整的历史记录以便推送
94+
fetch-depth: 0
11595

116-
# 添加此步骤以下载构建的站点内容 artifact
11796
- name: Download public directory artifact
11897
uses: actions/download-artifact@v4
11998
with:
120-
name: hugo-site-public # 与上传时使用的 artifact 名称一致
121-
path: ./public # 下载到当前工作目录的 ./public 路径
99+
name: hugo-site-public
100+
path: ./public
122101

123102
- name: Configure Git
124103
run: |
125104
git config user.name "github-actions[bot]"
126105
git config user.email "github-actions[bot]@users.noreply.github.com"
127106
128107
- name: Deploy to gh-pages branch
129-
uses: peaceiris/actions-gh-pages@v3 # 使用此Action来推送
130-
id: deployment # 为输出URL设置ID
108+
uses: peaceiris/actions-gh-pages@v3
109+
id: deployment
131110
with:
132111
github_token: ${{ secrets.GITHUB_TOKEN }}
133-
publish_dir: ./public # 指定要发布到gh-pages分支的目录
134-
publish_branch: gh-pages # 指定目标分支
112+
publish_dir: ./public
113+
publish_branch: gh-pages
135114
user_name: "github-actions[bot]"
136115
user_email: "github-actions[bot]@users.noreply.github.com"
137-
# 如果您的站点是项目页面(例如 username.github.io/repo-name/),
138-
# 并且您希望在gh-pages分支的根目录中包含子目录,请取消注释以下行
139-
# cname: example.com # 如果您有自定义域名,可以在这里设置
140-
# keep_files: true # 如果您想保留gh-pages分支上的现有文件

hugo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title = 'VNS'
77
[module]
88
[module.hugoVersion]
99
extended = true
10-
min = "0.148.2"
10+
min = "0.149.0"
1111

1212
[caches]
1313
[caches.assets]

0 commit comments

Comments
 (0)