Update pages.yml #10
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: github pages | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-docs: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
# 检出代码 | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
# 设置 Node.js 环境 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: current | |
registry-url: https://registry.npmjs.org/ | |
cache: pnpm | |
# 缓存 pnpm 依赖 | |
- name: Cache pnpm dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
# 安装依赖 | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
# 构建文档 | |
- name: Build project | |
run: pnpm run build | |
# 部署到 GitHub Pages | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./dist/ |