Skip to content

Commit

Permalink
deploy to gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
mac authored and mac committed Oct 4, 2024
1 parent d2e7c49 commit 9c2eef0
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy to GitHub Pages

on: [push]
permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

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

- name: Install Dependencies
run: pnpm install # 使用pnpm进行依赖安装

- name: Build
run: pnpm build # 使用pnpm进行构建
env:
GITHUB_PAGES: 'true'

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist # 要部署的文件夹,通常是构建输出目录
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "chess-analysis-web",
"name": "xiangqi-analysis-web",
"type": "module",
"version": "1.0.0",
"description": "Online chess endgame analysis application",
"description": "Online xiangqi endgame analysis application",
"main": "index.js",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview"
"preview": "vite preview",
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"
},
"dependencies": {
"@techstark/opencv-js": "^4.10.0-release.1",
Expand All @@ -19,5 +21,6 @@
"typescript": "^5.6.2",
"vite": "^5.4.8"
},
"packageManager": "[email protected]+sha512.4abf725084d7bcbafbd728bfc7bee61f2f791f977fd87542b3579dcb23504d170d46337945e4c66485cd12d588a0c0e570ed9c477e7ccdd8507cf05f3f92eaca"
"packageManager": "[email protected]+sha512.4abf725084d7bcbafbd728bfc7bee61f2f791f977fd87542b3579dcb23504d170d46337945e4c66485cd12d588a0c0e570ed9c477e7ccdd8507cf05f3f92eaca",
"homepage": "https://<your-github-username>.github.io/<your-repo-name>"
}
1 change: 1 addition & 0 deletions tsconfig.app.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":["./src/app.tsx","./src/chessengine.ts","./src/main.tsx","./src/vite-env.d.ts","./src/chessboard/chessboarddetection.ts","./src/chessboard/fengeneration.ts","./src/chessboard/movehelper.ts","./src/chessboard/overlaycreation.ts","./src/chessboard/piecedetection.ts","./src/chessboard/templatematching.ts","./src/chessboard/types.ts","./src/chessboard/utils.ts","./src/components/chessboarddisplay.tsx","./src/components/chessboardoverlay.tsx","./src/components/fendisplay.tsx","./src/components/imageuploader.tsx","./src/components/solutiondisplay.tsx"],"version":"5.6.2"}
1 change: 1 addition & 0 deletions tsconfig.node.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"root":["./vite.config.ts"],"version":"5.6.2"}
13 changes: 12 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';

declare const process: {
env: {
GITHUB_PAGES?: string;
};
};

// 检查是否是 GitHub Pages 环境
const isGitHubPages = process.env.GITHUB_PAGES === 'true';

export default defineConfig({
plugins: [ preact() ],
server: {
Expand All @@ -22,4 +31,6 @@ export default defineConfig({
optimizeDeps: {
include: [ 'pikafish' ],
},
});
// 根据环境动态设置 base
base: isGitHubPages ? '/xiangqi-analysis/' : '/',
});

0 comments on commit 9c2eef0

Please sign in to comment.