From 7bdcf07d562efeaa4761a193a031f47bf8163ea4 Mon Sep 17 00:00:00 2001 From: xiaoquan <838115837@qq.com> Date: Wed, 10 Jun 2026 16:40:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20CI/CD=20=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=20-=20=E7=A7=BB=E9=99=A4=20actions/checkout?= =?UTF-8?q?=20=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 问题 - actions/checkout@v4 需要 Node.js 环境 - Gitea Act Runner 默认镜像没有 Node.js - 导致 "Cannot find: node in PATH" 错误 ## 解决方案 - 使用原生 git 命令代替 actions/checkout - 在 install job 中安装 Node.js 环境 - 所有 checkout 步骤改为 git clone ## 优点 - 不依赖 GitHub Actions 插件 - 完全使用原生命令,更稳定 - 适合国内服务器环境 Co-Authored-By: Claude Opus 4.7 --- .gitea/workflows/deploy.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 2257db0..68b401b 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -13,7 +13,15 @@ jobs: install: runs-on: [self-hosted, rent-deploy] steps: - - uses: actions/checkout@v4 + - name: Checkout code + run: | + git clone --depth 1 --branch ${GITHUB_REF#refs/heads/} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git . + git checkout ${GITHUB_SHA} + + - name: Setup Node.js + run: | + curl -fsSL https://deb.nodesource.com/setup_18.x | bash - + apt-get install -y nodejs - name: Install dependencies run: | @@ -25,7 +33,10 @@ jobs: runs-on: [self-hosted, rent-deploy] needs: install steps: - - uses: actions/checkout@v4 + - name: Checkout code + run: | + git clone --depth 1 --branch ${GITHUB_REF#refs/heads/} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git . + git checkout ${GITHUB_SHA} - name: Build shared packages run: | @@ -52,7 +63,10 @@ jobs: needs: build if: github.ref == 'refs/heads/prod' steps: - - uses: actions/checkout@v4 + - name: Checkout code + run: | + git clone --depth 1 --branch ${GITHUB_REF#refs/heads/} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git . + git checkout ${GITHUB_SHA} - name: Deploy to production run: | @@ -74,7 +88,10 @@ jobs: needs: build if: github.ref == 'refs/heads/test' steps: - - uses: actions/checkout@v4 + - name: Checkout code + run: | + git clone --depth 1 --branch ${GITHUB_REF#refs/heads/} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git . + git checkout ${GITHUB_SHA} - name: Deploy to test run: |