Skip to content

Commit 3b3e8bd

Browse files
nextjs.yml added
1 parent 148d264 commit 3b3e8bd

File tree

2 files changed

+13492
-0
lines changed

2 files changed

+13492
-0
lines changed

.github/workflows/nextjs.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
#
5+
name: Deploy Next.js site to Pages
6+
7+
on:
8+
push:
9+
branches: ["main"]
10+
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- name: Detect package manager
29+
id: detect-package-manager
30+
run: |
31+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
32+
echo "manager=yarn" >> $GITHUB_OUTPUT
33+
echo "command=install" >> $GITHUB_OUTPUT
34+
echo "runner=yarn" >> $GITHUB_OUTPUT
35+
exit 0
36+
elif [ -f "${{ github.workspace }}/package.json" ]; then
37+
echo "manager=npm" >> $GITHUB_OUTPUT
38+
echo "command=ci" >> $GITHUB_OUTPUT
39+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
40+
exit 0
41+
else
42+
echo "Unable to determine package manager"
43+
exit 1
44+
fi
45+
- name: Setup Node
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: "20"
49+
cache: ${{ steps.detect-package-manager.outputs.manager }}
50+
- name: Setup Pages
51+
uses: actions/configure-pages@v5
52+
with:
53+
# Automatically inject basePath in your Next.js configuration file and disable
54+
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
55+
#
56+
# You may remove this line if you want to manage the configuration yourself.
57+
static_site_generator: next
58+
- name: Restore cache
59+
uses: actions/cache@v4
60+
with:
61+
path: |
62+
.next/cache
63+
# Generate a new cache whenever packages or source files change.
64+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
65+
# If source files changed but packages didn't, rebuild from a prior cache.
66+
restore-keys: |
67+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
68+
- name: Install dependencies
69+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
70+
- name: Build with Next.js
71+
run: ${{ steps.detect-package-manager.outputs.runner }} next build
72+
- name: Upload artifact
73+
uses: actions/upload-pages-artifact@v3
74+
with:
75+
path: ./out
76+
77+
# Deployment job
78+
deploy:
79+
environment:
80+
name: github-pages
81+
url: ${{ steps.deployment.outputs.page_url }}
82+
runs-on: ubuntu-latest
83+
needs: build
84+
steps:
85+
- name: Deploy to GitHub Pages
86+
id: deployment
87+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)