Skip to content

Commit e9c2f2d

Browse files
committed
adding back the github action for backward compatibility
1 parent 4d5e892 commit e9c2f2d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Deploy Vite App to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
21+
- name: Setup Pnpm
22+
- uses: pnpm/action-setup@v4
23+
24+
- name: Install dependencies
25+
run: pnpm install
26+
27+
- name: Build project
28+
run: pnpm build
29+
30+
- name: Fix paths for GitHub Pages
31+
run: |
32+
node <<EOF
33+
const fs = require('fs');
34+
const path = require('path');
35+
36+
const repoName = process.env.GITHUB_REPOSITORY.split('/')[1];
37+
const distDir = path.resolve('dist');
38+
const indexFile = path.join(distDir, 'index.html');
39+
40+
let html = fs.readFileSync(indexFile, 'utf-8');
41+
html = html.replace(/src="\//g, `src="/${repoName}/`);
42+
html = html.replace(/href="\//g, `href="/${repoName}/`);
43+
44+
fs.writeFileSync(indexFile, html);
45+
console.log('Paths updated for GitHub Pages.');
46+
EOF
47+
48+
- name: Deploy to GitHub Pages
49+
uses: peaceiris/actions-gh-pages@v3
50+
with:
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
publish_dir: dist

0 commit comments

Comments
 (0)