Skip to content

Commit e3f024d

Browse files
committed
update action
1 parent 14719b5 commit e3f024d

File tree

1 file changed

+21
-29
lines changed

1 file changed

+21
-29
lines changed

.github/workflows/nextjs.yml

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,32 @@
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:
3221
- name: Checkout
33-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
23+
3424
- name: Detect package manager
3525
id: detect-package-manager
3626
run: |
3727
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
3828
echo "manager=yarn" >> $GITHUB_OUTPUT
39-
echo "command=install" >> $GITHUB_OUTPUT
29+
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
4030
echo "runner=yarn" >> $GITHUB_OUTPUT
4131
exit 0
4232
elif [ -f "${{ github.workspace }}/package.json" ]; then
@@ -48,41 +38,41 @@ jobs:
4838
echo "Unable to determine package manager"
4939
exit 1
5040
fi
41+
5142
- name: Setup Node
52-
uses: actions/setup-node@v3
43+
uses: actions/setup-node@v4
5344
with:
54-
node-version: "16"
45+
node-version: "20"
5546
cache: ${{ steps.detect-package-manager.outputs.manager }}
47+
5648
- name: Setup Pages
57-
uses: actions/configure-pages@v3
49+
uses: actions/configure-pages@v4
5850
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.
6351
static_site_generator: next
64-
- name: Restore cache
65-
uses: actions/cache@v3
52+
53+
- name: Restore Next.js cache
54+
uses: actions/cache@v4
6655
with:
67-
path: |
68-
.next/cache
69-
# Generate a new cache whenever packages or source files change.
56+
path: .next/cache
7057
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.
7258
restore-keys: |
7359
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
60+
7461
- name: Install dependencies
7562
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
63+
7664
- name: Build with Next.js
7765
run: ${{ steps.detect-package-manager.outputs.runner }} next build
66+
7867
- name: Static HTML export with Next.js
7968
run: ${{ steps.detect-package-manager.outputs.runner }} next export
69+
8070
- name: Upload artifact
81-
uses: actions/upload-pages-artifact@v2
71+
uses: actions/upload-artifact@v4
8272
with:
73+
name: nextjs-site
8374
path: ./out
8475

85-
# Deployment job
8676
deploy:
8777
environment:
8878
name: github-pages
@@ -92,4 +82,6 @@ jobs:
9282
steps:
9383
- name: Deploy to GitHub Pages
9484
id: deployment
95-
uses: actions/deploy-pages@v2
85+
uses: actions/deploy-pages@v4
86+
with:
87+
artifact_name: nextjs-site

0 commit comments

Comments
 (0)