Skip to content

Commit 4a0d03e

Browse files
2 parents 5fc9468 + b82c7d4 commit 4a0d03e

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/nextjs.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Workflow for building and deploying a Next.js site to GitHub Pages
2+
name: Deploy Next.js site to Pages
3+
4+
on:
5+
# Trigger on pushes to the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allow manual triggering from the Actions tab
10+
workflow_dispatch:
11+
12+
# Set permissions for deployment
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one deployment at a time
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
# Build job
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: "20"
35+
cache: "yarn"
36+
37+
- name: Install dependencies
38+
run: yarn install
39+
40+
- name: Configure Next.js for GitHub Pages
41+
run: |
42+
echo 'module.exports = { output: "export", basePath: "/<REPOSITORY-NAME>", trailingSlash: true }' > next.config.js
43+
cat next.config.js
44+
45+
- name: Build Next.js site
46+
run: yarn next build && yarn next export
47+
48+
- name: Upload artifact
49+
uses: actions/upload-pages-artifact@v3
50+
with:
51+
path: out
52+
53+
# Deployment job
54+
deploy:
55+
environment:
56+
name: github-pages
57+
url: ${{ steps.deployment.outputs.page_url }}
58+
runs-on: ubuntu-latest
59+
needs: build
60+
steps:
61+
- name: Deploy to GitHub Pages
62+
id: deployment
63+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)