ci: 新增流水线 #2
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 | |
| on: | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - README.md | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v5 | |
| - name: 设置 pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: 设置 Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: 缓存 pnpm store | |
| uses: actions/cache@v4 | |
| id: pnpm-cache | |
| with: | |
| path: ~/.local/share/pnpm/store | |
| key: pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} | |
| restore-keys: | | |
| pnpm-store- | |
| - name: 安装依赖 | |
| run: pnpm install --frozen-lockfile | |
| - name: 构建 | |
| run: pnpm build | |
| - name: 部署到 GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: main # 部署目标分支 | |
| target-folder: docs # 部署目标文件夹 | |
| folder: dist # 构建输出目录 | |
| clean: true # 自动清理旧文件 | |
| single-commit: true # 减少 commit 历史,让分支更干净 | |
| commit-message: 自动部署 # 自定义 commit message |