1010
1111env :
1212 CACHE_KEY : ' hugo-hinode-template'
13- CACHE_PATH_DEBIAN : ' /tmp/hugo_cache_runner'
14- CACHE_PATH_WIN : ' ~\AppData\Local\hugo_cache'
15- CACHE_PATH_MAC : ' /Users/runner/Library/Caches/hugo_cache'
13+
14+ permissions :
15+ pull-requests : read
16+ contents : read
1617
1718jobs :
1819 lint :
3435 run : npm i
3536
3637 - name : Lint the source files
37- run : npm run lint
38+ run : npm run lint
3839
3940 build :
4041 needs : lint
@@ -44,17 +45,27 @@ jobs:
4445 os : [macos-latest, windows-latest, ubuntu-latest]
4546 # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
4647 node-version : [22.x, 24.x]
48+ include :
49+ - os : ubuntu-latest
50+ hugo_cachedir : ' /tmp/hugo_cache_runner'
51+ - os : macos-latest
52+ hugo_cachedir : ' /Users/runner/Library/Caches/hugo_cache'
53+ - os : windows-latest
54+ hugo_cachedir : ' ~\AppData\Local\hugo_cache'
4755
4856 runs-on : ${{ matrix.os }}
4957
58+ env :
59+ HUGO_CACHEDIR : ${{ matrix.hugo_cachedir }}
60+
5061 steps :
5162 - name : Check out repository
5263 uses : actions/checkout@v6
5364
5465 - name : Install Go
5566 uses : actions/setup-go@v6
5667 with :
57- go-version : " >1.0.0 "
68+ go-version : " stable "
5869
5970 - name : Set up Node.js ${{ matrix.node-version }}
6071 uses : actions/setup-node@v6
6475 cache-dependency-path : ' **/package-lock.json'
6576
6677 - name : Install Dart Sass
67- run : |
78+ env :
79+ DART_SASS_VERSION : " 1.98.0"
80+ run : |
6881 if [ "$RUNNER_OS" == "Linux" ]; then
69- sudo snap install dart-sass
82+ curl -fsSL "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" \
83+ | tar -xz -C "$HOME"
84+ echo "$HOME/dart-sass" >> $GITHUB_PATH
7085 elif [ "$RUNNER_OS" == "macOS" ]; then
7186 brew install sass/sass/sass
7287 elif [ "$RUNNER_OS" == "Windows" ]; then
@@ -76,23 +91,34 @@ jobs:
7691
7792 # [24/AUG/23] Adjusted from npm ci for non-macOS to prevent EBADPLATFORM error due to fsevents
7893 - name : Perform clean install of npm
79- run : |
94+ run : |
8095 if [ "$RUNNER_OS" == "macOS" ]; then
8196 npm ci
8297 else
8398 npm i
8499 fi
85100 shell : bash
86101
87- # Cache Hugo cachedir and resourcedir (configured in config/ci/hugo.toml) for each OS
88- # No additional cache invalidation is needed, Hugo uses checksums itself
102+ # On Windows, HUGO_CACHEDIR is initialised from the matrix as '~\AppData\Local\hugo_cache'.
103+ # Hugo requires an absolute path, so expand ~ to %LOCALAPPDATA% before using the cache.
104+ - name : Expand Hugo cache directory on Windows
105+ if : runner.os == 'Windows'
106+ run : echo "HUGO_CACHEDIR=$env:LOCALAPPDATA\hugo_cache" >> $env:GITHUB_ENV
107+ shell : pwsh
108+
109+ # Cache Hugo cachedir and resourcedir (configured in config/ci/hugo.toml) for each OS.
110+ # Rolling key restores the previous snapshot as a warm start, then saves a fresh one after build.
111+ # No additional content-based invalidation is needed; Hugo uses checksums itself.
89112 - name : Use Hugo cache
90113 uses : actions/cache@v5
91114 with :
92- path : ${{ runner.os == 'Windows' && env.CACHE_PATH_WIN || runner.os == 'macOS' && env.CACHE_PATH_MAC || env.CACHE_PATH_DEBIAN }}
93- key : ${{ runner.os }}-${{ env.CACHE_KEY }}
115+ path : ${{ env.HUGO_CACHEDIR }}
116+ key : ${{ runner.os }}-${{ env.CACHE_KEY }}-${{ github.run_id }}
94117 restore-keys : |
95- ${{ runner.os }}-${{ env.CACHE_KEY }}
118+ ${{ runner.os }}-${{ env.CACHE_KEY }}-
119+
120+ - name : Display environment
121+ run : npm run env
96122
97123 - name : Build main site
98124 run : npm run build:cache
0 commit comments