Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy Demo to GitHub Pages

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

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 pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build package with types
run: pnpm --filter tps-controls build

- name: Build demo for GitHub Pages
run: pnpm --filter demo build:github

- name: Create .nojekyll file
run: touch demo/dist/.nojekyll

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: demo/dist

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"build:github": "vite build --base=/TPS-Controls/",
"build:github-with-types": "tsc -b && vite build --base=/TPS-Controls/",
"preview": "vite preview"
},
"dependencies": {
Expand Down
9 changes: 7 additions & 2 deletions demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vite.dev/config/
export default defineConfig({
export default defineConfig(({ command, mode }) => ({
plugins: [react()],
})
base: mode === 'production' ? '/TPS-Controls/' : '/',
build: {
outDir: 'dist',
assetsDir: 'assets',
},
}))
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"dev:watch": "concurrently \"pnpm --filter tps-controls dev\" \"pnpm --filter demo dev\"",
"build": "pnpm --filter tps-controls build",
"build:demo": "pnpm --filter demo build",
"build:github": "pnpm run build && pnpm --filter demo build:github",
"deploy:github": "pnpm run build:github && echo '✅ Demo built for GitHub Pages! Push to main branch to deploy.'",
"publish:package": "pnpm run build && pnpm --filter tps-controls publish",
"test": "pnpm --filter '*' test",
"lint": "eslint . --ext .ts,.tsx",
Expand Down