Skip to content

Commit d381d35

Browse files
authored
feat: add auto deploy of example page (#275)
1 parent 9623cdf commit d381d35

4 files changed

Lines changed: 83 additions & 19 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy Example to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
concurrency:
13+
group: 'pages'
14+
cancel-in-progress: false
15+
16+
jobs:
17+
deploy:
18+
environment:
19+
name: github-pages
20+
url: ${{ steps.deployment.outputs.page_url }}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Setup Node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version-file: '.nvmrc'
29+
cache: 'npm'
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Build example
35+
run: npm run build:example
36+
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v5
39+
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
path: './example-dist'
44+
45+
- name: Deploy to GitHub Pages
46+
id: deployment
47+
uses: actions/deploy-pages@v4

example/index.html

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
3+
<head>
4+
<meta charset="UTF-8" />
55
<title>React Frame Component Examples</title>
66
<style>
7-
* {
8-
color: blue;
9-
}
10-
iframe {
11-
width: 100%;
12-
}
13-
section {
14-
display: grid;
15-
grid-template-columns: repeat(2, 1fr);
16-
}
7+
* {
8+
color: blue;
9+
}
10+
iframe {
11+
width: 100%;
12+
}
13+
section {
14+
display: grid;
15+
grid-template-columns: repeat(2, 1fr);
16+
}
1717
</style>
18-
</head>
19-
<body>
20-
<h1>&lt;Frame /> examples</h1>
21-
<p>Two examples below showing how you can encapsulate individual components or your entire application</p>
22-
<section>
18+
</head>
19+
<body>
20+
<h1>&lt;Frame /> examples</h1>
21+
<p>
22+
Two examples below showing how you can encapsulate individual components
23+
or your entire application
24+
</p>
25+
<section>
2326
<div id="example1"></div>
2427
<div id="example2"></div>
2528
<div id="example3"></div>
2629
</section>
27-
</body>
30+
<script type="module" src="./app.jsx"></script>
31+
</body>
2832
</html>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"serve": "vite --root example",
2424
"start": "npm run serve",
2525
"build": "vite build",
26+
"build:example": "vite build --config vite.example.config.js",
2627
"lint": "eslint src test",
2728
"prepublish": "npm run build",
2829
"deploy": "gh-pages -d dist",

vite.example.config.js

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

0 commit comments

Comments
 (0)