修复示例项目路径 #3
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: Build and Deploy Example | |
# 用于描述工作流的何时触发 | |
on: | |
workflow_dispatch: {} | |
push: | |
branches: [main] | |
pull_request: | |
branches: | |
- main | |
# 设置GITHUB_TOKEN的权限 | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: pages | |
cancel-in-progress: false | |
# 工作流里的任务 | |
jobs: | |
# 构建 | |
build: | |
# 指定该任务运行的系统,目前可选的有 ubuntu、windows、和 macOS | |
runs-on: ubuntu-latest | |
# 任务里的运行步骤 | |
steps: | |
# 代码检出 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# 安装 Node.js | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
# 配置 github pages | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
# 安装 pnpm | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
# 设置 pnpm 缓存目录 | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
# 安装依赖 | |
- name: Install dependencies | |
run: pnpm install --no-frozen-lockfile | |
# 插件打包 | |
- name: Build plugin | |
run: pnpm build | |
# 示例项目打包 | |
- name: Build with VitePress | |
run: | | |
pnpm docs:build | |
touch docs/.vitepress/dist/.nojekyll | |
# 上传到 Github Pages 部署环境 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: docs/.vitepress/dist | |
# 部署到GitHubPages | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
# 部署 GitHub Pages | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |