From 4c16e58e6b62aaf83689b207fc6f74a107dd9f82 Mon Sep 17 00:00:00 2001 From: antior Date: Mon, 20 Jul 2026 12:23:20 +0800 Subject: [PATCH] Replace actions/checkout with instance git clone (github.com unreachable from runner) --- .gitea/workflows/build.yaml | 10 +++++++++- README.md | 14 +++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 97595ec..eb6c12f 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -10,8 +10,16 @@ jobs: build: runs-on: windows-latest steps: + # runner 到 github.com 网络不稳定,不使用 actions/checkout@v4, + # 改为直接从本 Gitea 实例克隆代码 - name: Checkout - uses: actions/checkout@v4 + shell: pwsh + env: + GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + $url = "${{ gitea.server_url }}/${{ github.repository }}.git" -replace '^https://', "https://x-access-token:$env:GITEA_TOKEN@" + git clone $url . + git checkout ${{ github.sha }} - name: Install dependencies run: npm ci diff --git a/README.md b/README.md index 0e1c365..56812c2 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,19 @@ Gitea Actions 自托管 runner 的测试仓库,同时作为其他仓库编写 - 默认 shell 是 PowerShell,写 run 步骤时用 PowerShell 语法, 或显式声明 shell: pwsh;不要写 bash 语法 - 路径用 Windows 规则;产物打包用 Compress-Archive -- actions/checkout@v4 等 GitHub 官方 action 可用(runner 可访问 github.com 和 npm/pypi registry) +- runner 到 github.com 的网络不稳定,【禁止使用 actions/checkout@v4 等托管在 github.com 的 action】, + 拉代码必须用下面的实例克隆步骤(npm/pypi registry 可正常访问) + +【拉取代码(代替 actions/checkout,shell: pwsh)】 + + - name: Checkout + shell: pwsh + env: + GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + $url = "${{ gitea.server_url }}/${{ github.repository }}.git" -replace '^https://', "https://x-access-token:$env:GITEA_TOKEN@" + git clone $url . + git checkout ${{ github.sha }} 【Release 发布方式】 用 Gitea API 发布,token 用自动注入的 ${{ secrets.GITHUB_TOKEN }},