Replace actions/checkout with instance git clone (github.com unreachable from runner)
build-and-release / build (push) Successful in 4s

This commit is contained in:
2026-07-20 12:23:20 +08:00
parent a9a554ac69
commit 4c16e58e6b
2 changed files with 22 additions and 2 deletions
+9 -1
View File
@@ -10,8 +10,16 @@ jobs:
build: build:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
# runner 到 github.com 网络不稳定,不使用 actions/checkout@v4
# 改为直接从本 Gitea 实例克隆代码
- name: Checkout - 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 - name: Install dependencies
run: npm ci run: npm ci
+13 -1
View File
@@ -26,7 +26,19 @@ Gitea Actions 自托管 runner 的测试仓库,同时作为其他仓库编写
- 默认 shell 是 PowerShell,写 run 步骤时用 PowerShell 语法, - 默认 shell 是 PowerShell,写 run 步骤时用 PowerShell 语法,
或显式声明 shell: pwsh;不要写 bash 语法 或显式声明 shell: pwsh;不要写 bash 语法
- 路径用 Windows 规则;产物打包用 Compress-Archive - 路径用 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/checkoutshell: 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 发布方式】 【Release 发布方式】
用 Gitea API 发布,token 用自动注入的 ${{ secrets.GITHUB_TOKEN }} 用 Gitea API 发布,token 用自动注入的 ${{ secrets.GITHUB_TOKEN }}