feat: 开发者通道 #225
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, master ] # 自动触发分支 | |
| pull_request: | |
| branches: [ main, master ] # PR 触发(仅测试,不实际部署) | |
| workflow_dispatch: # ✅ 手动触发 | |
| inputs: | |
| target_branch: | |
| description: '要部署的分支(默认 main)' | |
| required: false | |
| default: 'main' | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.target_branch || github.ref_name }} | |
| persist-credentials: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Clean and install dependencies | |
| run: | | |
| rm -rf node_modules package-lock.json | |
| npm install --force | |
| - name: Build | |
| run: npm run build | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| # ✅ 支持 push 或手动触发两种情况 | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| github.ref == 'refs/heads/main' || | |
| github.ref == 'refs/heads/master' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist | |
| keep_files: false |