generated from gethinode/template
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (78 loc) · 2.49 KB
/
lint-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
- 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: [18.x, 20.x]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- 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@v3
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