@@ -4,7 +4,8 @@ name: Deploy Hugo site to Pages
44on :
55 # Runs on pushes targeting the default branch
66 push :
7- branches : ["master"]
7+ branches :
8+ - master
89
910 # Allows you to run this workflow manually from the Actions tab
1011 workflow_dispatch :
@@ -15,10 +16,11 @@ permissions:
1516 pages : write
1617 id-token : write
1718
18- # Allow one concurrent deployment
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.
1921concurrency :
2022 group : " pages"
21- cancel-in-progress : true
23+ cancel-in-progress : false
2224
2325# Default to bash
2426defaults :
@@ -29,25 +31,51 @@ jobs:
2931 # Build job
3032 build :
3133 runs-on : ubuntu-latest
34+ env :
35+ HUGO_VERSION : 0.124.1
36+ HUGO_ENVIRONMENT : production
37+ TZ : Asia/Shanghai
3238 steps :
33- - name : Setup Hugo
34- uses : peaceiris/actions-hugo@v2
35- with :
36- hugo-version : " 0.124.1"
37- extended : true
39+ - name : Install Hugo CLI
40+ run : |
41+ wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
42+ && sudo dpkg -i ${{ runner.temp }}/hugo.deb
43+ - name : Install Dart Sass
44+ run : sudo snap install dart-sass
3845 - name : Checkout
39- uses : actions/checkout@v3
46+ uses : actions/checkout@v4
47+ with :
48+ submodules : recursive
49+ fetch-depth : 0
4050 - name : Setup Pages
4151 id : pages
42- uses : actions/configure-pages@v2
52+ uses : actions/configure-pages@v5
4353 - name : Install Node.js dependencies
4454 run : " [[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
55+ - name : Cache Restore
56+ id : cache-restore
57+ uses : actions/cache/restore@v4
58+ with :
59+ path : |
60+ ${{ runner.temp }}/hugo_cache
61+ key : hugo-${{ github.run_id }}
62+ restore-keys : hugo-
63+ - name : Configure Git
64+ run : git config core.quotepath false
4565 - name : Build with Hugo
46- env :
47- # For maximum backward compatibility with Hugo modules
48- HUGO_ENVIRONMENT : production
49- HUGO_ENV : production
50- run : hugo --minify
66+ run : |
67+ hugo \
68+ --gc \
69+ --minify \
70+ --baseURL "${{ steps.pages.outputs.base_url }}/" \
71+ --cacheDir "${{ runner.temp }}/hugo_cache"
72+ - name : Cache Save
73+ id : cache-save
74+ uses : actions/cache/save@v4
75+ with :
76+ path : |
77+ ${{ runner.temp }}/hugo_cache
78+ key : ${{ steps.cache-restore.outputs.cache-primary-key }}
5179 - name : Upload artifact
5280 uses : actions/upload-pages-artifact@v3
5381 with :
6391 steps :
6492 - name : Deploy to GitHub Pages
6593 id : deployment
66- uses : actions/deploy-pages@v1
94+ uses : actions/deploy-pages@v4
0 commit comments