From 3bf10930d7ca4a245b596d6fd91de1500496c34e Mon Sep 17 00:00:00 2001 From: chufan Date: Tue, 22 Sep 2026 16:40:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E9=94=81=E5=AE=9A=20Node=2025.9.0?= =?UTF-8?q?=20/=20pnpm=209.15.0=20=E5=B9=B6=E5=8D=87=E7=BA=A7=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CD.yaml | 42 +++++++++++++-------------- .github/workflows/CI.yml | 41 +++++++++++++------------- .github/workflows/codeql-analysis.yml | 4 +-- Dockerfile | 2 +- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml index d2e5f76..1e21bb1 100644 --- a/.github/workflows/CD.yaml +++ b/.github/workflows/CD.yaml @@ -11,10 +11,12 @@ on: - next workflow_dispatch: -# # vercel 环境变量 env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + # Node / pnpm 版本与 package.json、.nvmrc 保持一致 + NODE_VERSION: 25.9.0 + PNPM_VERSION: 9.15.0 # 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages permissions: @@ -26,7 +28,7 @@ jobs: # 部署到Github-Pages deploy-github: name: 部署到Github-Pages - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -34,24 +36,23 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: persist-credentials: false # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 fetch-depth: 0 - # 安装PNPM + # 安装 PNPM(版本与 package.json packageManager 一致) - name: PNPM Install - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v5 with: - version: 9.6.0 + version: ${{ env.PNPM_VERSION }} - # 安装Node环境 + # 安装 Node 环境(版本与 .nvmrc / engines.node 一致) - name: Install Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: - node-version: 20.16.0 - # 缓存 + node-version: ${{ env.NODE_VERSION }} cache: pnpm - name: Install Dependencies @@ -63,42 +64,41 @@ jobs: run: pnpm build:proxy - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: path: .vuepress/dist # 部署 - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v5 # 版本发布 release: name: Github版本发布 - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # # 主库main、next且执行release更新时执行 if: github.repository == '142vip/408CSFamily' && startsWith(github.event.head_commit.message, 'chore(release):') steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: persist-credentials: false # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 fetch-depth: 0 - # 安装PNPM + # 安装 PNPM(版本与 package.json packageManager 一致) - name: PNPM Install - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v5 with: - version: 9.6.0 + version: ${{ env.PNPM_VERSION }} - # 安装Node环境 + # 安装 Node 环境(版本与 .nvmrc / engines.node 一致) - name: Install Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: - node-version: 20.16.0 - # 缓存 + node-version: ${{ env.NODE_VERSION }} cache: pnpm - name: Install Dependencies diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1c2bff9..9376f61 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,11 +22,14 @@ env: # 阿里云仓库信息 REGISTRY: registry.cn-hangzhou.aliyuncs.com UserName: 142vip + # Node / pnpm 版本与 package.json、.nvmrc 保持一致 + NODE_VERSION: 25.9.0 + PNPM_VERSION: 9.15.0 jobs: Base-Build: name: 基础编译构建 - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # 主库且拉取PR时触发 if: github.repository == '142vip/408CSFamily' && github.event_name == 'pull_request' permissions: @@ -35,27 +38,26 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: persist-credentials: false # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 fetch-depth: 0 - # 安装PNPM + # 安装 PNPM(版本与 package.json packageManager 一致) - name: PNPM Install - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v5 with: - version: 9.6.0 + version: ${{ env.PNPM_VERSION }} - # 安装Node环境 + # 安装 Node 环境(版本与 .nvmrc / engines.node 一致) - name: Install Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: - node-version: 20.16.0 - # # 缓存 + node-version: ${{ env.NODE_VERSION }} cache: pnpm - # 下载依赖,并执行初始化脚本:钩子函数、思维导图构建 + # 下载依赖,并执行初始化脚本 - name: Install Dependencies run: | ./scripts/ci @@ -74,7 +76,7 @@ jobs: Build-Docker-Image: name: 构建Docker镜像 - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # 主库且tag更新时执行 if: github.repository == '142vip/408CSFamily' && startsWith(github.event.head_commit.message, 'chore(release):') permissions: @@ -83,7 +85,7 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: persist-credentials: false # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 @@ -104,21 +106,20 @@ jobs: --password=${{ secrets.DOCKER_PASSWORD }} \ ${{env.REGISTRY}} - # 安装PNPM + # 安装 PNPM(版本与 package.json packageManager 一致) - name: PNPM Install - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v5 with: - version: 9.6.0 + version: ${{ env.PNPM_VERSION }} - # 安装Node环境 + # 安装 Node 环境(版本与 .nvmrc / engines.node 一致) - name: Install Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: - node-version: 20.16.0 - # # 缓存 + node-version: ${{ env.NODE_VERSION }} cache: pnpm - # 下载依赖,并执行初始化脚本:钩子函数、思维导图构建 + # 下载依赖,并执行初始化脚本 - name: Install Dependencies run: | ./scripts/ci diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7a86a56..1e8d198 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -11,11 +11,11 @@ on: jobs: analyze: name: Analyze - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/Dockerfile b/Dockerfile index 8670ffe..731ac1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ # - 参数: # APP_VERSION: 版本 # -# 注意:vite构建需要支持node14以上,安装node16较为稳妥 +# 构建阶段使用 infra 基础镜像(含 Node 25 + corepack),pnpm 版本由 package.json 的 packageManager 锁定 FROM registry.cn-hangzhou.aliyuncs.com/142vip-infra/node:25.9.0-base AS build_base ARG NEED_PROXY