Skip to content

Commit ca0fa61

Browse files
committed
use pnpm on github action to deploy site
1 parent e07d410 commit ca0fa61

File tree

1 file changed

+20
-38
lines changed

1 file changed

+20
-38
lines changed

.github/workflows/nextjs.yml

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,65 @@
1-
# Sample workflow for building and deploying a Next.js site to GitHub Pages
2-
#
3-
# To get started with Next.js see: https://nextjs.org/docs/getting-started
4-
#
51
name: Deploy Next.js site to Pages
62

73
on:
8-
# Runs on pushes targeting the default branch
94
push:
105
branches: ["main"]
11-
12-
# Allows you to run this workflow manually from the Actions tab
136
workflow_dispatch:
147

15-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
168
permissions:
179
contents: read
1810
pages: write
1911
id-token: write
2012

21-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2313
concurrency:
2414
group: "pages"
2515
cancel-in-progress: false
2616

2717
jobs:
28-
# Build job
2918
build:
3019
runs-on: ubuntu-latest
3120
env:
3221
NEXT_TELEMETRY_DISABLED: 1
3322
steps:
3423
- name: Checkout
3524
uses: actions/checkout@v4
36-
- name: Detect package manager
37-
id: detect-package-manager
38-
run: |
39-
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
40-
echo "manager=yarn" >> $GITHUB_OUTPUT
41-
echo "command=install" >> $GITHUB_OUTPUT
42-
echo "runner=yarn" >> $GITHUB_OUTPUT
43-
exit 0
44-
elif [ -f "${{ github.workspace }}/package.json" ]; then
45-
echo "manager=npm" >> $GITHUB_OUTPUT
46-
echo "command=ci" >> $GITHUB_OUTPUT
47-
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
48-
exit 0
49-
else
50-
echo "Unable to determine package manager"
51-
exit 1
52-
fi
25+
26+
# Setup pnpm (v10) and Node.js
27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: 10
5331
- name: Setup Node
5432
uses: actions/setup-node@v4
5533
with:
5634
node-version: "20"
57-
cache: ${{ steps.detect-package-manager.outputs.manager }}
35+
cache: "pnpm"
36+
5837
- name: Setup Pages
5938
uses: actions/configure-pages@v5
60-
61-
- name: Restore cache
39+
40+
# Cache Next.js build cache (separate from pnpm cache above)
41+
- name: Restore Next.js cache
6242
uses: actions/cache@v4
6343
with:
6444
path: |
6545
.next/cache
66-
# Generate a new cache whenever packages or source files change.
67-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
68-
# If source files changed but packages didn't, rebuild from a prior cache.
46+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.[jt]s', '**/*.[jt]sx', '**/*.mdx') }}
6947
restore-keys: |
70-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
48+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
49+
7150
- name: Install dependencies
72-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
51+
run: pnpm install --frozen-lockfile
52+
7353
- name: Build with Next.js
74-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
54+
run: |
55+
pnpm run build
56+
pnpm exec next export
57+
7558
- name: Upload artifact
7659
uses: actions/upload-pages-artifact@v3
7760
with:
7861
path: ./out
7962

80-
# Deployment job
8163
deploy:
8264
environment:
8365
name: github-pages

0 commit comments

Comments
 (0)