-
Notifications
You must be signed in to change notification settings - Fork 58
88 lines (72 loc) · 2.19 KB
/
nextjs.yml
File metadata and controls
88 lines (72 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Deploy React Docs (Next.js) to GitHub Pages
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: Setup Yarn Classic
run: npm i -g yarn@1.22.22
- name: Setup GitHub Pages (Next.js)
uses: actions/configure-pages@v5
with:
static_site_generator: next
- name: Restore Next.js cache
uses: actions/cache@v4
with:
path: |
.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.[jt]s', '**/*.[jt]sx', '**/*.md', '**/*.mdx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build site
run: yarn build
- name: Patch encoded dynamic chunk filename for GitHub Pages
run: |
set -e
PAGES_CHUNKS_DIR="out/_next/static/chunks/pages"
if [ -d "$PAGES_CHUNKS_DIR" ]; then
for f in "$PAGES_CHUNKS_DIR"/\[\[...markdownPath\]\]-*.js; do
if [ -f "$f" ]; then
base="$(basename "$f")"
encoded="${base//\[\[...markdownPath\]\]/%5B%5B...markdownPath%5D%5D}"
cp "$f" "$PAGES_CHUNKS_DIR/$encoded"
fi
done
fi
- name: Verify output folder
run: |
ls -la
test -d out || (echo "ERROR: ./out not found after build" && exit 1)
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4