-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (79 loc) · 2.65 KB
/
Copy pathnextjs.yml
File metadata and controls
94 lines (79 loc) · 2.65 KB
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
94
name: Deploy Next.js to GitHub Pages
on:
push:
branches: ["next"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Detect package manager
id: pm
run: |
if [ -f bun.lockb ]; then
echo "manager=bun" >> $GITHUB_OUTPUT
echo "install=bun install" >> $GITHUB_OUTPUT
echo "run=bunx" >> $GITHUB_OUTPUT
elif [ -f yarn.lock ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "install=yarn install --frozen-lockfile" >> $GITHUB_OUTPUT
echo "run=yarn" >> $GITHUB_OUTPUT
elif [ -f pnpm-lock.yaml ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "install=pnpm install --frozen-lockfile" >> $GITHUB_OUTPUT
echo "run=pnpm" >> $GITHUB_OUTPUT
else
echo "manager=npm" >> $GITHUB_OUTPUT
echo "install=npm ci" >> $GITHUB_OUTPUT
echo "run=npx --no-install" >> $GITHUB_OUTPUT
fi
- name: Setup Bun
if: steps.pm.outputs.manager == 'bun'
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: ${{ steps.pm.outputs.manager != 'bun' && steps.pm.outputs.manager || '' }}
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
with:
static_site_generator: next
- name: Restore Next.js cache
uses: actions/cache@v5
with:
path: .next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json','**/yarn.lock','**/pnpm-lock.yaml','**/bun.lockb') }}-${{ hashFiles('**/*.{js,ts,jsx,tsx}') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json','**/yarn.lock','**/pnpm-lock.yaml','**/bun.lockb') }}-
- name: Install dependencies
run: ${{ steps.pm.outputs.install }}
- name: Build Next.js site
env:
NODE_ENV: production
run: ${{ steps.pm.outputs.run }} next build
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: ./out
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@v4