adding back the github action for backward compatibility #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Vite App to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| - name: Setup Pnpm | |
| - uses: pnpm/action-setup@v4 | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build project | |
| run: pnpm build | |
| - name: Fix paths for GitHub Pages | |
| run: | | |
| node <<EOF | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const repoName = process.env.GITHUB_REPOSITORY.split('/')[1]; | |
| const distDir = path.resolve('dist'); | |
| const indexFile = path.join(distDir, 'index.html'); | |
| let html = fs.readFileSync(indexFile, 'utf-8'); | |
| html = html.replace(/src="\//g, `src="/${repoName}/`); | |
| html = html.replace(/href="\//g, `href="/${repoName}/`); | |
| fs.writeFileSync(indexFile, html); | |
| console.log('Paths updated for GitHub Pages.'); | |
| EOF | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: dist |