ci: build with multiple Hugo versions and update caches

Add matrix strategy for 'latest' and '0.114.0' in build job. Update
pnpm and Hugo cache keys for better reliability. Push artifacts only
for 'latest' version. Add [skip ci] to format commit message.

Signed-off-by: Sped0n <hi@sped0n.com>
This commit is contained in:
Sped0n
2025-11-12 02:32:54 +08:00
committed by Ryan
parent 48eaa9d95b
commit ba46f52d55
2 changed files with 16 additions and 8 deletions

View File

@@ -33,11 +33,14 @@ jobs:
build:
timeout-minutes: 30
runs-on: ubuntu-latest
name: Build
name: Build (Hugo ${{ matrix.hugo-version }})
needs: [filter]
if: |
github.ref == 'refs/heads/main' &&
github.event.repository.fork == false
strategy:
matrix:
hugo-version: ['latest', '0.114.0']
steps:
- name: Set current date as env variable
run: |
@@ -52,7 +55,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.6.0
with:
hugo-version: '0.114.0'
hugo-version: ${{ matrix.hugo-version }}
extended: true
- name: Setup Dart Sass
@@ -71,15 +74,17 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('./pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup hugo cache
uses: actions/cache@v4
with:
path: ./exampleSite/resources
key: ${{ runner.os }}-hugo-${{ hashFiles('./exampleSite/resources') }}
restore-keys: ${{ runner.os }}-hugo-
key: ${{ runner.os }}-hugo-${{ matrix.hugo-version }}-${{ hashFiles('./exampleSite') }}
restore-keys: |
${{ runner.os }}-hugo-${{ matrix.hugo-version }}-
- name: Install dependencies
run: pnpm install
@@ -90,7 +95,10 @@ jobs:
hugo --logLevel info --source=exampleSite --gc --minify
- name: Push artifacts
if: ${{ (github.event_name == 'push' || github.event.pull_request.merged == true) && needs.filter.outputs.any_changed == 'true' }}
if: >
matrix.hugo-version == 'latest' &&
(github.event_name == 'push' || github.event.pull_request.merged == true) &&
needs.filter.outputs.any_changed == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'ci: update bundled artifacts [skip ci]'

View File

@@ -54,4 +54,4 @@ jobs:
if: ${{ steps.format.outcome == 'success' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'ci: format code'
commit_message: 'ci: format code [skip ci]'