From 19a6f131b5dc9bce6861dd1ee7e6278649150995 Mon Sep 17 00:00:00 2001 From: heming <74885943+984507092@users.noreply.github.com> Date: Sun, 28 Apr 2024 23:29:12 +0800 Subject: [PATCH 1/2] Update deploy.yml --- .github/workflows/deploy.yml | 55 +++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 02604bc..39cec55 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,61 +1,64 @@ +# Sample workflow for building and deploying a VitePress site to GitHub Pages +# name: Deploy VitePress site to Pages on: + # Runs on pushes targeting the `main` branch. Change this to `master` if you're + # using the `master` branch as the default branch. push: branches: [main] -# 设置tokenn访问权限 + # 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@v3 - with: - fetch-depth: 0 # 如果未启用 lastUpdated,则不需要 - - name: Setup pnpm - uses: pnpm/action-setup@v2 # 安装pnpm并添加到环境变量 + uses: actions/checkout@v4 with: - version: 8.6.12 # 指定需要的 pnpm 版本 + fetch-depth: 0 # Not needed if lastUpdated is not enabled + # - uses: pnpm/action-setup@v3 # Uncomment this if you're using pnpm + # - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun - name: Setup Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 - cache: pnpm # 设置缓存 + node-version: 20 + cache: npm # or pnpm / yarn - name: Setup Pages - uses: actions/configure-pages@v3 # 在工作流程自动配置GithubPages + uses: actions/configure-pages@v4 - name: Install dependencies - run: pnpm install # 安装依赖 + run: npm ci # or pnpm install / yarn install / bun install - name: Build with VitePress - run: | - pnpm run docs:build # 启动项目 - touch .nojekyll # 通知githubpages不要使用Jekyll处理这个站点,不知道为啥不生效,就手动搞了 + run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build - name: Upload artifact - uses: actions/upload-pages-artifact@v2 # 上传构建产物 + uses: actions/upload-pages-artifact@v3 with: - path: docs/.vitepress/dist # 指定上传的路径,当前是根目录,如果是docs需要加docs/的前缀 + path: docs/.vitepress/dist - # 部署工作 + # Deployment job deploy: environment: name: github-pages - url: ${{ steps.deployment.outputs.page_url }} # 从后续的输出中获取部署后的页面URL - needs: build # 在build后面完成 - runs-on: ubuntu-latest # 运行在最新版本的ubuntu系统上 + url: ${{ steps.deployment.outputs.page_url }} + needs: build + runs-on: ubuntu-latest name: Deploy steps: - name: Deploy to GitHub Pages - id: deployment # 指定id - uses: actions/deploy-pages@v2 # 将之前的构建产物部署到github pages中 + id: deployment + uses: actions/deploy-pages@v4 From 6e21e17c90df4144841302ad028fdd0cfd92c0dc Mon Sep 17 00:00:00 2001 From: heming <74885943+984507092@users.noreply.github.com> Date: Sun, 28 Apr 2024 23:36:08 +0800 Subject: [PATCH 2/2] Update deploy.yml --- .github/workflows/deploy.yml | 57 +++++++++++++++++------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 39cec55..44b4487 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,64 +1,61 @@ -# Sample workflow for building and deploying a VitePress site to GitHub Pages -# name: Deploy VitePress site to Pages on: - # Runs on pushes targeting the `main` branch. Change this to `master` if you're - # using the `master` branch as the default branch. push: - branches: [main] + 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 +# 设置tokenn访问权限 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 + uses: actions/checkout@v3 + with: + fetch-depth: 0 # 如果未启用 lastUpdated,则不需要 + - name: Setup pnpm + uses: pnpm/action-setup@v2 # 安装pnpm并添加到环境变量 with: - fetch-depth: 0 # Not needed if lastUpdated is not enabled - # - uses: pnpm/action-setup@v3 # Uncomment this if you're using pnpm - # - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun + version: 8.6.12 # 指定需要的 pnpm 版本 - name: Setup Node - uses: actions/setup-node@v4 + uses: actions/setup-node@v3 with: - node-version: 20 - cache: npm # or pnpm / yarn + node-version: 18 + cache: pnpm # 设置缓存 - name: Setup Pages - uses: actions/configure-pages@v4 + uses: actions/configure-pages@v3 # 在工作流程自动配置GithubPages - name: Install dependencies - run: npm ci # or pnpm install / yarn install / bun install + run: pnpm install # 安装依赖 - name: Build with VitePress - run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build + run: | + pnpm run docs:build # 启动项目 + touch .nojekyll # 通知githubpages不要使用Jekyll处理这个站点,不知道为啥不生效,就手动搞了 - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v2 # 上传构建产物 with: - path: docs/.vitepress/dist + path: docs/.vitepress/dist # 指定上传的路径,当前是根目录,如果是docs需要加docs/的前缀 - # Deployment job + # 部署工作 deploy: environment: name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - needs: build - runs-on: ubuntu-latest + url: ${{ steps.deployment.outputs.page_url }} # 从后续的输出中获取部署后的页面URL + needs: build # 在build后面完成 + runs-on: ubuntu-latest # 运行在最新版本的ubuntu系统上 name: Deploy steps: - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + id: deployment # 指定id + uses: actions/deploy-pages@v2 # 将之前的构建产物部署到github pages中