fix: fix deploy public path #21
This file contains 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 to GitHub Pages | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 检出代码 | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# 设置 Node.js 环境 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '14.15' | |
# 安装依赖 | |
- name: Install dependencies | |
run: npm install | |
# 构建项目 | |
- name: Build project | |
run: npm run build | |
# 调试构建输出 | |
- name: Debug build output | |
run: | | |
echo "Listing files in ./dist:" | |
ls -R ./dist | |
- name: Find and remove symlinks | |
run: find ./dist -type l -exec rm -f {} \; | |
# 上传构建文件为 artifact | |
- name: Upload artifact for deployment | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./dist | |
name: github-pages | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
# 调试:列出 workspace 中的文件 | |
- name: Debug - List uploaded artifacts | |
run: | | |
echo "Listing uploaded artifact files:" | |
ls -R $GITHUB_WORKSPACE | |
- name: Check if GITHUB_TOKEN is valid | |
run: echo ${{ secrets.TEST_GITHUB_TOKEN }} | base64 | |
# 部署到 GitHub Pages | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.TEST_GITHUB_TOKEN }} | |
publish_dir: ./dist |