Skip to content

Commit 6e5bfc6

Browse files
authored
Create pages.yml
1 parent c1a68e5 commit 6e5bfc6

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

.github/workflows/pages.yml

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

0 commit comments

Comments
 (0)