Skip to content

Commit cf4f45e

Browse files
authored
ci: demo deploy to github page (#26)
1 parent 9134400 commit cf4f45e

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

.github/workflows/demo.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy Demo
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+
env:
18+
NODE_VERSION: 22
19+
20+
jobs:
21+
deploy:
22+
environment:
23+
name: github-pages
24+
url: ${{ steps.deployment.outputs.page_url }}
25+
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Use Node.js ${{ env.NODE_VERSION }}
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: ${{ env.NODE_VERSION }}
35+
cache: 'npm'
36+
37+
- name: Install dependencies
38+
run: npm ci
39+
40+
- name: Build Demo
41+
run: npm run build:demo
42+
43+
- name: Setup Pages
44+
uses: actions/configure-pages@v5
45+
46+
- name: Upload artifact for Github page
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: 'demo'
50+
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
demo/

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"lint": "eslint .",
3232
"lint-fix": "eslint . --fix",
3333
"preview": "vite preview",
34-
"prepare": "husky && npm run build"
34+
"prepare": "husky && npm run build",
35+
"build:demo": "vite build --config vite-demo.config.ts"
3536
},
3637
"lint-staged": {
3738
"*": "eslint --fix"

vite-demo.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'vite'
2+
import react from '@vitejs/plugin-react'
3+
4+
export default defineConfig({
5+
plugins: [react()],
6+
base: './',
7+
build: {
8+
outDir: 'demo',
9+
emptyOutDir: true,
10+
},
11+
})

0 commit comments

Comments
 (0)