Skip to content

Commit b61a615

Browse files
committed
ci(demo): migrate deployment to GitHub Actions
Add GitHub Actions workflow to deploy the demo on v* tag pushes. The workflow validates that the tag version matches both package.json files before building and deploying to GitHub Pages. Remove the demo:push script and simplify demo:publish to only handle cleaning and building, as deployment is now handled by CI.
1 parent 6400bf5 commit b61a615

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

.github/workflows/demo-deploy.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Deploy Demo
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
18+
- name: Validate versions match
19+
run: |
20+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
21+
ROOT_VERSION=$(node -p "require('./package.json').version")
22+
DEMO_VERSION=$(node -p "require('./demo/package.json').version")
23+
if [ "$TAG_VERSION" != "$ROOT_VERSION" ]; then
24+
echo "::error::Tag version ($TAG_VERSION) does not match root package.json ($ROOT_VERSION)"
25+
exit 1
26+
fi
27+
if [ "$TAG_VERSION" != "$DEMO_VERSION" ]; then
28+
echo "::error::Tag version ($TAG_VERSION) does not match demo package.json ($DEMO_VERSION)"
29+
exit 1
30+
fi
31+
echo "All versions match: $TAG_VERSION"
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 24
37+
cache: npm
38+
39+
- name: Install root dependencies
40+
run: npm ci
41+
42+
- name: Install demo dependencies
43+
working-directory: demo
44+
run: npm ci
45+
46+
- name: Build demo
47+
run: npm run demo:build
48+
49+
- name: Deploy to GitHub Pages
50+
uses: peaceiris/actions-gh-pages@v4
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
publish_dir: ./demo/dist
54+
force_orphan: true

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
"demo:clean": "rimraf demo/dist",
4242
"demo:dev": "cd demo && npm run dev",
4343
"demo:build": "cd demo && npm run build",
44-
"demo:push": "cd demo/dist && git init && git commit --allow-empty -m 'update demo' && git checkout -b gh-pages && git add . && git commit -am 'update demo' && git push git@github.com:orrisroot/react-html-parser gh-pages --force",
45-
"demo:publish": "npm run demo:clean && npm run demo:build && npm run demo:push"
44+
"demo:publish": "npm run demo:clean && npm run demo:build"
4645
},
4746
"repository": {
4847
"type": "git",

0 commit comments

Comments
 (0)