Skip to content

Commit a2f9691

Browse files
committed
Use custom action to download hugo, cache results in CI
1 parent d1a74d3 commit a2f9691

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

.github/workflows/hugo.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ jobs:
3030
runs-on: ubuntu-latest
3131
env:
3232
HUGO_VERSION: 0.145.0
33+
HUGO_CACHE_DIR: /tmp/hugo_cache
34+
HUGO_ENVIRONMENT: production
3335
steps:
34-
- name: Install Hugo CLI
35-
run: sudo snap install hugo --channel=extended
36-
37-
- name: Install Dart Sass
38-
run: sudo snap install dart-sass
36+
- name: Setup hugo
37+
uses: peaceiris/actions-hugo@v3
38+
with:
39+
hugo-version: ${{ env.HUGO_VERSION }}
40+
extended: true
3941

4042
- name: Install Node.js
4143
uses: actions/setup-node@v3
@@ -47,6 +49,14 @@ jobs:
4749
id: pages
4850
uses: actions/configure-pages@v5
4951

52+
- name: Setup hugo cache
53+
uses: actions/cache@v4
54+
with:
55+
path: ${{ env.HUGO_CACHEDIR }}
56+
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/config.toml') }}
57+
restore-keys: |
58+
${{ runner.os }}-hugomod-
59+
5060
- name: Checkout
5161
uses: actions/checkout@v4
5262
with:
@@ -56,8 +66,8 @@ jobs:
5666
- name: Build with Hugo
5767
env:
5868
# For maximum backward compatibility with Hugo modules
59-
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
60-
HUGO_ENVIRONMENT: production
69+
HUGO_CACHEDIR: ${{ env.HUGO_CACHE_DIR }}
70+
HUGO_ENVIRONMENT: ${{ env.HUGO_ENVIRONMENT }}
6171
run: |
6272
hugo \
6373
--minify \

0 commit comments

Comments
 (0)