11# 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- #
52name : Deploy Next.js site to Pages
63
74on :
@@ -18,8 +15,6 @@ permissions:
1815 pages : write
1916 id-token : write
2017
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.
2318concurrency :
2419 group : " pages"
2520 cancel-in-progress : false
3126 steps :
3227 - name : Checkout
3328 uses : actions/checkout@v4
29+
3430 - name : Detect package manager
3531 id : detect-package-manager
3632 run : |
@@ -48,33 +44,22 @@ jobs:
4844 echo "Unable to determine package manager"
4945 exit 1
5046 fi
47+
5148 - name : Setup Node
5249 uses : actions/setup-node@v4
5350 with :
5451 node-version : " 20"
5552 cache : ${{ steps.detect-package-manager.outputs.manager }}
56- - name : Setup Pages
57- uses : actions/configure-pages@v5
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@v4
66- 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') }}-
53+
7454 - name : Install dependencies
7555 run : ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
56+
7657 - name : Build with Next.js
7758 run : ${{ steps.detect-package-manager.outputs.runner }} next build
59+
60+ - name : Export Next.js site
61+ run : ${{ steps.detect-package-manager.outputs.runner }} next export
62+
7863 - name : Upload artifact
7964 uses : actions/upload-pages-artifact@v3
8065 with :
0 commit comments