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

View File

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