Skip to content

Commit bb93062

Browse files
authored
Update GitHub Actions workflow for Next.js deployment
1 parent b79449a commit bb93062

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

.github/workflows/nextjs.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Deploy React Docs (Next.js) to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js 20
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "20"
29+
cache: "yarn"
30+
31+
- name: Setup Yarn Classic
32+
run: npm i -g yarn@1.22.22
33+
34+
- name: Setup GitHub Pages (Next.js)
35+
uses: actions/configure-pages@v5
36+
with:
37+
static_site_generator: next
38+
39+
- name: Restore Next.js cache
40+
uses: actions/cache@v4
41+
with:
42+
path: |
43+
.next/cache
44+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.[jt]s', '**/*.[jt]sx', '**/*.md', '**/*.mdx') }}
45+
restore-keys: |
46+
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
47+
48+
- name: Install dependencies
49+
run: yarn install --frozen-lockfile
50+
51+
- name: Build site
52+
run: yarn build
53+
54+
- name: Verify output folder
55+
run: |
56+
ls -la
57+
test -d out || (echo "ERROR: ./out not found after build" && exit 1)
58+
59+
- name: Upload Pages artifact
60+
uses: actions/upload-pages-artifact@v3
61+
with:
62+
path: ./out
63+
64+
deploy:
65+
needs: build
66+
runs-on: ubuntu-latest
67+
environment:
68+
name: github-pages
69+
url: ${{ steps.deployment.outputs.page_url }}
70+
71+
steps:
72+
- name: Deploy to GitHub Pages
73+
id: deployment
74+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)