ci: fix runner probe curl error and re-sync RELEASE_TOKEN
Some checks failed
Secrets CLI - Build & Release / 版本 & Release (push) Successful in 2s
Secrets CLI - Build & Release / 探测 Runner (push) Successful in 1s
Secrets CLI - Build & Release / 质量检查 (fmt / clippy / test) (push) Successful in 23s
Secrets CLI - Build & Release / Build (aarch64-apple-darwin) (push) Successful in 20s
Secrets CLI - Build & Release / Build (x86_64-unknown-linux-musl) (push) Successful in 27s
Secrets CLI - Build & Release / 通知 (push) Has been cancelled
Secrets CLI - Build & Release / Build (x86_64-pc-windows-msvc) (push) Has been cancelled
Some checks failed
Secrets CLI - Build & Release / 版本 & Release (push) Successful in 2s
Secrets CLI - Build & Release / 探测 Runner (push) Successful in 1s
Secrets CLI - Build & Release / 质量检查 (fmt / clippy / test) (push) Successful in 23s
Secrets CLI - Build & Release / Build (aarch64-apple-darwin) (push) Successful in 20s
Secrets CLI - Build & Release / Build (x86_64-unknown-linux-musl) (push) Successful in 27s
Secrets CLI - Build & Release / 通知 (push) Has been cancelled
Secrets CLI - Build & Release / Build (x86_64-pc-windows-msvc) (push) Has been cancelled
- 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
This commit is contained in:
@@ -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"
|
||||
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 "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"
|
||||
echo "${key}=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
done
|
||||
|
||||
check:
|
||||
name: 质量检查 (fmt / clippy / test)
|
||||
|
||||
Reference in New Issue
Block a user