seo #159
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 到 docs 分支时触发部署 | |
| # Deployment is triggered whenever a push is made to the docs branch. | |
| push: | |
| branches: [docs] | |
| # 手动触发部署 | |
| # Manually trigger deployment | |
| workflow_dispatch: | |
| jobs: | |
| docs: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # Needed for auth with Deno Deploy | |
| contents: read # Needed to clone the repository | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # "最近更新时间" 等 git 日志相关信息,需要拉取全部提交记录 | |
| # "Last updated time" and other git log-related information require fetching all commit records. | |
| fetch-depth: 0 | |
| # 克隆 Karin 源码仓库 | |
| # Clone Karin source repository | |
| - name: Checkout Karin source | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: KarinJS/Karin | |
| path: karin-source | |
| fetch-depth: 1 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| # 选择要使用的 node 版本 | |
| node-version: 22 | |
| # 安装 Karin 源码依赖并生成 TypeDoc | |
| # Install Karin source dependencies and generate TypeDoc | |
| - name: Install Karin dependencies and generate docs | |
| run: | | |
| cd karin-source | |
| pnpm install --frozen-lockfile | |
| cd packages/core | |
| pnpm run docs:build | |
| # 复制生成的 TypeDoc 到文档项目 | |
| # Copy generated TypeDoc to docs project | |
| - name: Copy TypeDoc to docs project | |
| run: | | |
| # 删除旧的 types 目录 | |
| rm -rf docs/guide/api/types | |
| # 复制新生成的文档 | |
| cp -r karin-source/packages/core/guide/api/types docs/guide/api/ | |
| # 复制 typedoc-sidebar.json 到 VuePress collections 目录 | |
| cp karin-source/packages/core/guide/api/types/typedoc-sidebar.json docs/.vuepress/collections/typedoc-sidebar.json | |
| # 清理源码目录 | |
| rm -rf karin-source | |
| # 安装依赖 | |
| # Install dependencies | |
| - name: Install Dependencies | |
| run: pnpm install --frozen-lockfile | |
| # 运行构建脚本 | |
| # Run the build script | |
| - name: Build VuePress site | |
| run: pnpm run build | |
| # 将docs/CNAME文件复制到docs/.vuepress/dist目录下 | |
| - name: Copy CNAME | |
| run: cp docs/CNAME docs/.vuepress/dist/CNAME | |
| # 查看 workflow 的文档来获取更多信息 | |
| # @see https://github.com/crazy-max/ghaction-github-pages | |
| - name: Deploy to GitHub Pages | |
| uses: crazy-max/ghaction-github-pages@v4 | |
| with: | |
| # 部署到 gh-pages 分支 | |
| target_branch: gh-pages | |
| # 部署目录为 VuePress 的默认输出目录 | |
| build_dir: docs/.vuepress/dist | |
| env: | |
| # @see https://docs.github.com/cn/actions/reference/authentication-in-a-workflow#about-the-github_token-secret | |
| GITHUB_TOKEN: ${{ secrets.DOCS_TOKEN }} | |
| # rm CNAME | |
| - name: Remove CNAME | |
| run: rm -f docs/.vuepress/dist/CNAME | |
| - name: Install Deno | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: v2.x | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| - name: Upload to Deno Deploy | |
| uses: denoland/deployctl@v1 | |
| with: | |
| project: karin | |
| entrypoint: https://deno.land/std@0.217.0/http/file_server.ts | |
| root: docs/.vuepress/dist | |
| # # cp vercel.json | |
| # - name: cp vercel.json | |
| # run: cp vercel.json docs/.vuepress/dist/vercel.json | |
| - name: Push to hanhan0258/karin-docs | |
| id: push-to-hanhan | |
| uses: peaceiris/actions-gh-pages@v3 | |
| continue-on-error: true | |
| with: | |
| personal_token: ${{ secrets.HANHAN_PUSH }} | |
| external_repository: hanhan0258/karin-docs | |
| publish_branch: gh-pages | |
| publish_dir: docs/.vuepress/dist | |
| force: true | |
| force_orphan: true | |
| user_name: 'github-actions[bot]' | |
| user_email: 'github-actions[bot]@users.noreply.github.com' | |
| - name: Check hanhan0258/karin-docs push status | |
| if: steps.push-to-hanhan.outcome == 'failure' | |
| run: | | |
| echo "::error::推送到 hanhan0258/karin-docs 仓库失败" | |
| echo "错误信息: ${{ steps.push-to-hanhan.outputs.error }}" | |
| - name: Push to yusheng929/karin-docs | |
| id: push-to-yusheng | |
| uses: peaceiris/actions-gh-pages@v3 | |
| continue-on-error: true | |
| with: | |
| personal_token: ${{ secrets.YUSHENG }} | |
| external_repository: yusheng929/karin-docs | |
| publish_branch: gh-pages | |
| publish_dir: docs/.vuepress/dist | |
| force: true | |
| force_orphan: true | |
| user_name: 'github-actions[bot]' | |
| user_email: 'github-actions[bot]@users.noreply.github.com' | |
| - name: Check yusheng929/karin-docs push status | |
| if: steps.push-to-yusheng.outcome == 'failure' | |
| run: | | |
| echo "::error::推送到 yusheng929/karin-docs 仓库失败" | |
| echo "错误信息: ${{ steps.push-to-yusheng.outputs.error }}" |