Skip to content

Commit d47522c

Browse files
committed
update action
1 parent 14719b5 commit d47522c

File tree

2 files changed

+17
-64
lines changed

2 files changed

+17
-64
lines changed

.github/workflows/nextjs.yml

Lines changed: 15 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,47 @@
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
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v3
34-
- name: Detect package manager
35-
id: detect-package-manager
36-
run: |
37-
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
38-
echo "manager=yarn" >> $GITHUB_OUTPUT
39-
echo "command=install" >> $GITHUB_OUTPUT
40-
echo "runner=yarn" >> $GITHUB_OUTPUT
41-
exit 0
42-
elif [ -f "${{ github.workspace }}/package.json" ]; then
43-
echo "manager=npm" >> $GITHUB_OUTPUT
44-
echo "command=ci" >> $GITHUB_OUTPUT
45-
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
46-
exit 0
47-
else
48-
echo "Unable to determine package manager"
49-
exit 1
50-
fi
51-
- name: Setup Node
52-
uses: actions/setup-node@v3
53-
with:
54-
node-version: "16"
55-
cache: ${{ steps.detect-package-manager.outputs.manager }}
56-
- name: Setup Pages
57-
uses: actions/configure-pages@v3
58-
with:
59-
# Automatically inject basePath in your Next.js configuration file and disable
60-
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
61-
#
62-
# You may remove this line if you want to manage the configuration yourself.
63-
static_site_generator: next
64-
- name: Restore cache
65-
uses: actions/cache@v3
21+
- uses: actions/checkout@v4
22+
23+
- uses: actions/setup-node@v4
6624
with:
67-
path: |
68-
.next/cache
69-
# Generate a new cache whenever packages or source files change.
70-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
71-
# If source files changed but packages didn't, rebuild from a prior cache.
72-
restore-keys: |
73-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
74-
- name: Install dependencies
75-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
76-
- name: Build with Next.js
77-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
78-
- name: Static HTML export with Next.js
79-
run: ${{ steps.detect-package-manager.outputs.runner }} next export
80-
- name: Upload artifact
81-
uses: actions/upload-pages-artifact@v2
25+
node-version: "20"
26+
cache: "npm"
27+
28+
- run: npm ci
29+
- run: npm run build
30+
- run: npm run export
31+
32+
- uses: actions/upload-artifact@v4
8233
with:
34+
name: nextjs-site
8335
path: ./out
8436

85-
# Deployment job
8637
deploy:
8738
environment:
8839
name: github-pages
8940
url: ${{ steps.deployment.outputs.page_url }}
9041
runs-on: ubuntu-latest
9142
needs: build
9243
steps:
93-
- name: Deploy to GitHub Pages
44+
- uses: actions/deploy-pages@v4
9445
id: deployment
95-
uses: actions/deploy-pages@v2
46+
with:
47+
artifact_name: nextjs-site

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint"
9+
"lint": "next lint",
10+
"export": "next export"
1011
},
1112
"dependencies": {
1213
"@types/node": "20.5.6",

0 commit comments

Comments
 (0)