From 2c1282e98dc1ccb68bbb6f5def462082b2354061 Mon Sep 17 00:00:00 2001 From: MKStoler1024 <158786854+MKStoler1024@users.noreply.github.com> Date: Fri, 31 Jan 2025 18:22:23 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=8C=E7=A7=BB=E9=99=A4=E6=97=A7?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E7=BD=B2=E6=96=87=E6=A1=A3=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E7=9A=84=20VitePress=20=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-docs.yml | 87 ------------------------------- .github/workflows/deploy.yml | 77 +++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 87 deletions(-) delete mode 100644 .github/workflows/deploy-docs.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml deleted file mode 100644 index 3a0e172..0000000 --- a/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,87 +0,0 @@ - -name: 部署文档 - -on: - push: - branches: - - main - -permissions: - contents: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - # 如果你文档需要 Git 子模块,取消注释下一行 - # submodules: true - - - name: 设置 pnpm - uses: pnpm/action-setup@v4 - with: - version: 9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1 - - - - name: 设置 Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: pnpm - - - name: 安装依赖 - run: | - corepack enable - pnpm install --frozen-lockfile - - - name: 构建文档 - env: - NODE_OPTIONS: --max_old_space_size=8192 - run: |- - pnpm run docs:build - > src/.vuepress/dist/.nojekyll - - - name: 打包工件 - shell: sh - if: runner.os == 'Linux' - run: | - tar \ - --directory "./src/.vuepress/dist/" \ - -cvf "$RUNNER_TEMP/artifact.tar" \ - --exclude=.git \ - --exclude=.github \ - . - env: - INPUT_PATH: ./build - - - name: 上传工件 - uses: actions/upload-artifact@v4 - with: - name: github-pages - path: ${{ runner.temp }}/artifact.tar - retention-days: 1 - if-no-files-found: error - - deploy: - # Add a dependency to the build job - needs: build - - # Grant GITHUB_TOKEN the permissions required to make a Pages deployment - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - - # Deploy to the github-pages environment - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - # Specify runner + deployment step - runs-on: ubuntu-latest - steps: - - name: 部署到 GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..dbbe6eb --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,77 @@ +# Sample workflow for building and deploying a Next.js site to GitHub Pages +# +# To get started with Next.js see: https://nextjs.org/docs/getting-started +# +name: Deploy VitePress site to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +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 job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: 设置 pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: pnpm + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Install dependencies + run: | + corepack enable + pnpm install --frozen-lockfile + - name: 构建文档 + env: + NODE_OPTIONS: --max_old_space_size=8192 + run: |- + pnpm run docs:build + > src/.vuepress/dist/.nojekyll + + - name: 删除不必要的文件夹 + run: |- + rm -rf src/.vuepress/dist/.nojekyll/.git + rm -rf src/.vuepress/dist/.nojekyll/.github + rm -rf src/.vuepress/dist/.nojekyll/.vscode + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: src/.vuepress/dist/.nojekyll + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file