From 2327e3a3b17e631a05efa83fc2ef16446012022b Mon Sep 17 00:00:00 2001 From: alboped Date: Sat, 11 Apr 2026 02:54:26 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E4=BC=98=E5=8C=96ci=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0a539f5..f8b097d 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -4,6 +4,8 @@ # # 说明:NODEJS_ORG_MIRROR 在 act_runner 中常被忽略/不生效;用镜像自带 Node 即可绕过。 # +# 不依赖 GitHub:不使用 actions/checkout、actions/cache,仅从当前 Gitea 实例 git fetch(需 Runner 能访问 Gitea)。 +# # 部署(推送到 main/master 时):在仓库「工作流 → 密钥」中配置 # SSH_PRIVATE_KEY DEPLOY_HOST DEPLOY_USER DEPLOY_PATH # DEPLOY_PATH 为站点父目录;实际发布目录为 ${DEPLOY_PATH}/chat.alboped.com(与 Nginx root 一致)。 @@ -26,8 +28,35 @@ jobs: runs-on: ubuntu-latest steps: + # 从本 Gitea 拉代码(github.* 为 Actions 兼容上下文;token 由 Gitea 注入) - name: Checkout - uses: actions/checkout@v4 + env: + TOKEN: ${{ github.token }} + run: | + set -e + export GIT_TERMINAL_PROMPT=0 + if ! command -v git >/dev/null 2>&1; then + export DEBIAN_FRONTEND=noninteractive + shopt -s nullglob + for f in /etc/apt/sources.list /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/*.sources /etc/apt/sources.list.d/*.list; do + [ -f "$f" ] || continue + sed -i \ + -e 's/deb.debian.org/mirrors.aliyun.com/g' \ + -e 's/security.debian.org/mirrors.aliyun.com/g' \ + "$f" + done + apt-get -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 -o Acquire::Retries=2 update + apt-get install -y --no-install-recommends git + fi + SERVER="${{ github.server_url }}" + SERVER="${SERVER%/}" + REPO="${{ github.repository }}" + ORIGIN="${SERVER/https:\/\//https:\/\/oauth2:${TOKEN}@}" + ORIGIN="${ORIGIN/http:\/\//http:\/\/oauth2:${TOKEN}@}/${REPO}.git" + git init + git remote add origin "$ORIGIN" + git fetch --depth 1 origin "${{ github.sha }}" + git checkout -f "${{ github.sha }}" # 使用 Job 镜像(node:22-bookworm)自带的 Node,不再使用 actions/setup-node,避免重复下载 Node - name: Setup Yarn @@ -37,14 +66,6 @@ jobs: echo "node -v: $(node -v); yarn -v: $(yarn -v)" echo "yarn config get registry: $(yarn config get registry)" - - name: Cache Yarn - uses: actions/cache@v4 - with: - path: ~/.cache/yarn - key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Install run: yarn install --frozen-lockfile