Skip to content

chore: add playground demo page #1

chore: add playground demo page

chore: add playground demo page #1

Workflow file for this run

name: Deploy playground demo # 工作流的名称
on: # 触发条件
push:
branches:
- main # 当 main 分支收到推送时触发
workflow_dispatch: # 允许手动触发
permissions: # GitHub token 的权限设置
contents: read # 读取仓库内容
pages: write # 写入 GitHub Pages
id-token: write # 写入身份令牌
concurrency: # 并发控制
group: pages # 同一时间只允许一个部署任务运行
cancel-in-progress: true # 如果有新的部署,取消正在进行的部署
jobs:
deploy:
environment: # 环境配置
name: github-pages # 环境名称
url: ${{ steps.deployment.outputs.page_url }} # 部署后的 URL
runs-on: ubuntu-latest # 运行环境
steps: # 执行步骤
# 1. 检出代码
- uses: actions/checkout@v4
# 2. 设置 pnpm
- uses: pnpm/action-setup@v2
with:
version: 9
# 3. 设置 Node.js
- uses: actions/setup-node@v4
with:
node-version: 18
cache: pnpm # 使用 pnpm 缓存
# 4. 安装依赖
- name: Install dependencies
run: pnpm install --frozen-lockfile # 使用 frozen-lockfile 确保依赖版本一致
# 5. 构建主库
- name: Build library
run: pnpm build
# 6. 构建演示页面
- name: Build playground
run: pnpm playground:build # 这里会自动运行版本生成脚本
# 添加缓存验证步骤
- name: Verify build
run: |
if [ ! -d "playground/dist" ]; then
echo "Playground build failed - dist directory not found"
exit 1
fi
# 7. 配置 GitHub Pages
- name: Setup Pages
uses: actions/configure-pages@v4
# 8. 上传构建产物
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: playground/dist # 指定要部署的目录
# 9. 部署到 GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4