Skip to content

Commit a7ba8e0

Browse files
committed
feat: add GitHub Pages deployment workflow for demo site
- Added GitHub Actions workflow to automatically deploy demo site to GitHub Pages - Configured Next.js for static export with proper base path and asset prefix for GitHub Pages - Added new build:gh script to generate GitHub Pages-compatible build - Set up concurrency controls to prevent parallel deployments - Configured necessary GitHub permissions for Pages deployment
1 parent c5d0cae commit a7ba8e0

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

.github/workflows/deploy-demo.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Deploy Demo (Next.js static export) 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: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build demo for GitHub Pages
34+
run: npm run build:gh --workspace=@crest-ui/demo
35+
36+
- name: Upload static site
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: apps/demo/out
40+
41+
deploy:
42+
needs: build
43+
runs-on: ubuntu-latest
44+
environment:
45+
name: github-pages
46+
url: ${{ steps.deployment.outputs.page_url }}
47+
steps:
48+
- id: deployment
49+
uses: actions/deploy-pages@v4

apps/demo/next.config.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
/** @type {import('next').NextConfig} */
2+
const isGhPages = process.env.GITHUB_PAGES === 'true';
3+
24
const nextConfig = {
35
transpilePackages: ["@crest-ui/ui", "@crest-ui/config", "@crest-ui/tokens"],
6+
output: 'export',
7+
trailingSlash: true,
8+
...(isGhPages
9+
? {
10+
basePath: '/crest-ui',
11+
assetPrefix: '/crest-ui/',
12+
}
13+
: {})
414
};
515

6-
export default nextConfig;
16+
export default nextConfig;

apps/demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"dev": "next dev -p 3000",
77
"build": "next build",
8+
"build:gh": "GITHUB_PAGES=true next build",
89
"start": "next start -p 3000",
910
"lint": "next lint"
1011
},

0 commit comments

Comments
 (0)