初始化EmbedKit工作流系统 #1
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: | |
| - master | |
| workflow_dispatch: # 允许手动触发 | |
| # 设置GITHUB_TOKEN权限 | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # 确保同时只有一个部署在运行 | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| collect-docs: | |
| name: 收集和处理文档 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 获取完整历史记录,用于获取最后修改时间 | |
| - name: 设置Node.js环境 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: '.github/scripts/package.json' | |
| - name: 安装依赖 | |
| run: | | |
| cd .github/scripts | |
| npm install --only=production | |
| - name: 收集README文件 | |
| run: | | |
| echo "开始收集项目中的README文件..." | |
| node .github/scripts/collect-readme.js | |
| - name: 生成文档索引 | |
| run: | | |
| echo "生成docsify目录索引..." | |
| node .github/scripts/generate-sidebar.js | |
| - name: 验证文档结构 | |
| run: | | |
| echo "验证生成的文档结构..." | |
| ls -la docs/ | |
| echo "--- _sidebar.md 内容 ---" | |
| cat docs/_sidebar.md | |
| - name: 设置Pages | |
| uses: actions/configure-pages@v4 | |
| - name: 构建文档站点 | |
| run: | | |
| # 复制docsify配置到docs目录 | |
| cp .docsify/index.html docs/ | |
| # 创建.nojekyll文件,防止GitHub Pages处理下划线文件 | |
| touch docs/.nojekyll | |
| # 创建CNAME文件(如果需要自定义域名) | |
| # echo "your-domain.com" > docs/CNAME | |
| echo "文档站点构建完成" | |
| - name: 上传Pages制品 | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/ | |
| deploy: | |
| name: 部署到GitHub Pages | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: collect-docs | |
| steps: | |
| - name: 部署到GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: 部署成功通知 | |
| run: | | |
| echo "✅ 文档已成功部署到GitHub Pages" | |
| echo "📖 访问地址: ${{ steps.deployment.outputs.page_url }}" |