Forcing things #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint & build | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- v* | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
CACHE_KEY: 'hugo-hinode-template' | |
CACHE_PATH_DEBIAN: '/tmp/hugo_cache_runner' | |
CACHE_PATH_WIN: '~\AppData\Local\hugo_cache' | |
CACHE_PATH_MAC: '/Users/runner/Library/Caches/hugo_cache' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: 'npm' | |
cache-dependency-path: '**/package-lock.json' | |
# [24/AUG/23] Adjusted from npm ci to prevent EBADPLATFORM error due to fsevents | |
- name: Install npm | |
run: npm i --force | |
- name: Lint the source files | |
run: npm run lint | |
build: | |
needs: lint | |
strategy: | |
matrix: | |
os: [macos-latest, windows-latest, ubuntu-latest] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
node-version: [20.x, 22.x] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ">1.0.0" | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
cache-dependency-path: '**/package-lock.json' | |
- name: Install Dart Sass | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
sudo snap install dart-sass | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
brew install sass/sass/sass | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
choco install sass | |
fi | |
shell: bash | |
# [24/AUG/23] Adjusted from npm ci for non-macOS to prevent EBADPLATFORM error due to fsevents | |
- name: Perform clean install of npm | |
run: | | |
if [ "$RUNNER_OS" == "macOS" ]; then | |
npm ci | |
else | |
npm i | |
fi | |
shell: bash | |
# Cache Hugo cachedir and resourcedir (configured in config/ci/hugo.toml) for each OS | |
# No additional cache invalidation is needed, Hugo uses checksums itself | |
- name: Use Hugo cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ runner.os == 'Windows' && env.CACHE_PATH_WIN || runner.os == 'macOS' && env.CACHE_PATH_MAC || env.CACHE_PATH_DEBIAN }} | |
key: ${{ runner.os }}-${{ env.CACHE_KEY }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.CACHE_KEY }} | |
- name: Build main site | |
run: npm run build:cache |