Skip to content

chore: update GitHub actions version and add .nvmrc, node-version-file #249

chore: update GitHub actions version and add .nvmrc, node-version-file

chore: update GitHub actions version and add .nvmrc, node-version-file #249

Workflow file for this run

name: Build Next.js site
on:
pull_request:
branches:
- main
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
uses: ./.github/actions/detect-package-manager
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Setup Pages
uses: actions/configure-pages@v4
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.manager }} run build
- name: Static HTML export with Next.js
# In versions of Next.js 13.3.0 and later, the next export command is no longer used. Instead, static exports can only be done with the next build. Therefore, the following steps may need to be removed or modified
run: ${{ steps.detect-package-manager.outputs.runner }} next export
- name: Optimize all static images after the Next.js static export
run: ${{ steps.detect-package-manager.outputs.runner }} next-image-export-optimizer
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out