修复GitHub Actions构建问题:使用npm install --legacy-peer-deps替代npm ci #3
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 to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main # 当主分支有提交时触发 | |
| # 设置部署权限 | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout 代码 | |
| uses: actions/checkout@v3 | |
| - name: 设置 Node.js 环境 | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: 安装依赖 | |
| run: npm install --legacy-peer-deps | |
| - name: 构建项目 | |
| run: npm run build | |
| - name: 部署到 GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| folder: dist # Vite 默认的构建输出目录 | |
| branch: gh-pages # 部署到的分支 | |
| clean: true # 部署前清理分支 |