-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 1.86 KB
/
deploy.yml
File metadata and controls
74 lines (63 loc) · 1.86 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
name: Build & Deploy Hugo site to GitHub Pages
on:
push:
branches:
- master # 如果你的主分支是 master / main,调整为正确的分支名
# 保留手动触发
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: '0.151.0'
NODE_VERSION: '22.x'
TZ: 'Asia/Taipei'
steps:
- name: Checkout source
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
- name: Setup Node.js (optional)
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Hugo
run: |
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir -p ~/.local/hugo
tar -C ~/.local/hugo -xf hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz
echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}"
- name: Verify Hugo version
run: hugo version
- name: Install Node dependencies (if needed)
run: |
if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then
npm ci
else
echo "No Node dependencies to install"
fi
- name: Build the site
run: |
hugo --gc --minify --baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: ./public
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@v4