From d2a0fd14e05ef6b0b9fca454f8996faf86f94204 Mon Sep 17 00:00:00 2001 From: Anoduck <9925396+anoduck@users.noreply.github.com> Date: Sun, 8 Sep 2024 14:54:54 +0000 Subject: Initial commit --- .github/workflows/lint-build.yml | 98 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/lint-build.yml (limited to '.github/workflows/lint-build.yml') diff --git a/.github/workflows/lint-build.yml b/.github/workflows/lint-build.yml new file mode 100644 index 0000000..7228fef --- /dev/null +++ b/.github/workflows/lint-build.yml @@ -0,0 +1,98 @@ +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: [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 -- cgit v1.2.3