From 1aef267bbdd1f9b06a8bca200d17cf2d198d9744 Mon Sep 17 00:00:00 2001 From: voson Date: Wed, 18 Mar 2026 15:18:03 +0800 Subject: [PATCH] ci: fix runner probe curl error and re-sync RELEASE_TOKEN - Replace curl -fsS with HTTP status code check in probe-runners to avoid ugly 401 errors - Graceful fallback: API failure defaults to trying all platforms - RELEASE_TOKEN re-synced with correct PAT value Made-with: Cursor --- .gitea/workflows/secrets.yml | 50 ++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/.gitea/workflows/secrets.yml b/.gitea/workflows/secrets.yml index d078957..f156cef 100644 --- a/.gitea/workflows/secrets.yml +++ b/.gitea/workflows/secrets.yml @@ -141,28 +141,31 @@ jobs: env: RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} run: | - if [ -z "$RELEASE_TOKEN" ]; then + fallback_all() { echo "has_linux=true" >> "$GITHUB_OUTPUT" echo "has_macos=true" >> "$GITHUB_OUTPUT" echo "has_windows=true" >> "$GITHUB_OUTPUT" - exit 0 + } + + if [ -z "$RELEASE_TOKEN" ]; then + echo "未配置 RELEASE_TOKEN,默认尝试所有平台" + fallback_all; exit 0 fi command -v jq >/dev/null 2>&1 || (sudo apt-get update -qq && sudo apt-get install -y -qq jq) - runners=$(curl -fsS -H "Authorization: token $RELEASE_TOKEN" \ - "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/runners" || true) + http_code=$(curl -sS -o /tmp/runners.json -w '%{http_code}' \ + -H "Authorization: token $RELEASE_TOKEN" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/runners") - if [ -z "$runners" ]; then - echo "has_linux=true" >> "$GITHUB_OUTPUT" - echo "has_macos=true" >> "$GITHUB_OUTPUT" - echo "has_windows=true" >> "$GITHUB_OUTPUT" - exit 0 + if [ "$http_code" != "200" ]; then + echo "Runner API 返回 HTTP ${http_code},默认尝试所有平台" + fallback_all; exit 0 fi has_runner() { local label="$1" - printf '%s' "$runners" | jq -e --arg label "$label" ' + jq -e --arg label "$label" ' (.runners // .data // . // []) | any( ( @@ -175,26 +178,17 @@ jobs: | index($label) ) != null ) - ' >/dev/null + ' /tmp/runners.json >/dev/null } - if has_runner "debian"; then - echo "has_linux=true" >> "$GITHUB_OUTPUT" - else - echo "has_linux=false" >> "$GITHUB_OUTPUT" - fi - - if has_runner "darwin-arm64"; then - echo "has_macos=true" >> "$GITHUB_OUTPUT" - else - echo "has_macos=false" >> "$GITHUB_OUTPUT" - fi - - if has_runner "windows"; then - echo "has_windows=true" >> "$GITHUB_OUTPUT" - else - echo "has_windows=false" >> "$GITHUB_OUTPUT" - fi + for pair in "debian:has_linux" "darwin-arm64:has_macos" "windows:has_windows"; do + label="${pair%%:*}"; key="${pair##*:}" + if has_runner "$label"; then + echo "${key}=true" >> "$GITHUB_OUTPUT" + else + echo "${key}=false" >> "$GITHUB_OUTPUT" + fi + done check: name: 质量检查 (fmt / clippy / test)