




























@@ -287,7 +287,7 @@ jobs:
287287 printf '%s\n' "$output"
288288 return 0
289289 fi
290- if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* ]]; then
290+ if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* || "$output" == *"Sorry. Your account was suspended"* ]]; then
291291 echo "::warning::gh $* failed on attempt ${attempt}: ${output}" >&2
292292 sleep $((attempt * 10))
293293 continue
@@ -417,7 +417,7 @@ jobs:
417417 printf '%s\n' "$output"
418418 return 0
419419 fi
420- if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* ]]; then
420+ if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* || "$output" == *"Sorry. Your account was suspended"* ]]; then
421421 echo "::warning::gh $* failed on attempt ${attempt}: ${output}" >&2
422422 sleep $((attempt * 10))
423423 continue
@@ -557,7 +557,7 @@ jobs:
557557 printf '%s\n' "$output"
558558 return 0
559559 fi
560- if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* ]]; then
560+ if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* || "$output" == *"Sorry. Your account was suspended"* ]]; then
561561 echo "::warning::gh $* failed on attempt ${attempt}: ${output}" >&2
562562 sleep $((attempt * 10))
563563 continue
@@ -859,7 +859,7 @@ jobs:
859859 printf '%s\n' "$output"
860860 return 0
861861 fi
862- if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* ]]; then
862+ if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* || "$output" == *"Sorry. Your account was suspended"* ]]; then
863863 echo "::warning::gh $* failed on attempt ${attempt}: ${output}" >&2
864864 sleep $((attempt * 10))
865865 continue
@@ -975,7 +975,7 @@ jobs:
975975 printf '%s\n' "$output"
976976 return 0
977977 fi
978- if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* ]]; then
978+ if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* || "$output" == *"Sorry. Your account was suspended"* ]]; then
979979 echo "::warning::gh $* failed on attempt ${attempt}: ${output}" >&2
980980 sleep $((attempt * 10))
981981 continue
@@ -1089,6 +1089,29 @@ jobs:
10891089run: |
10901090 set -euo pipefail
109110911092+ gh_with_retry() {
1093+ local output status attempt
1094+ for attempt in 1 2 3 4 5 6; do
1095+ set +e
1096+ output="$(gh "$@" 2>&1)"
1097+ status=$?
1098+ set -e
1099+ if [[ "$status" -eq 0 ]]; then
1100+ printf '%s\n' "$output"
1101+ return 0
1102+ fi
1103+ if [[ "$output" == *"Bad credentials"* || "$output" == *"HTTP 401"* || "$output" == *"secondary rate limit"* || "$output" == *"API rate limit"* || "$output" == *"Sorry. Your account was suspended"* ]]; then
1104+ echo "::warning::gh $* failed on attempt ${attempt}: ${output}" >&2
1105+ sleep $((attempt * 10))
1106+ continue
1107+ fi
1108+ printf '%s\n' "$output" >&2
1109+ return "$status"
1110+ done
1111+ printf '%s\n' "$output" >&2
1112+ return "$status"
1113+ }
1114+10921115 release_check_blocking_job() {
10931116 case "$1" in
10941117 "resolve_target" | \
@@ -1145,7 +1168,7 @@ jobs:
11451168 fi
1146116911471170 local run_json status conclusion url attempt head_sha
1148- run_json="$(gh run view "$run_id" --json status,conclusion,url,attempt,headSha,jobs)"
1171+ run_json="$(gh_with_retry run view "$run_id" --json status,conclusion,url,attempt,headSha,jobs)"
11491172 status="$(jq -r '.status' <<< "$run_json")"
11501173 conclusion="$(jq -r '.conclusion' <<< "$run_json")"
11511174 url="$(jq -r '.url' <<< "$run_json")"
@@ -1192,7 +1215,7 @@ jobs:
11921215 fi
1193121611941217 local run_json row
1195- run_json="$(gh run view "$run_id" --json status,conclusion,url,createdAt,updatedAt,headSha)"
1218+ run_json="$(gh_with_retry run view "$run_id" --json status,conclusion,url,createdAt,updatedAt,headSha)"
11961219 row="$(
11971220 jq -r --arg label "$label" '
11981221 def ts: fromdateiso8601;
@@ -1228,7 +1251,7 @@ jobs:
12281251 echo
12291252 echo "### Slowest jobs: ${label}"
12301253 echo
1231- gh run view "$run_id" --json jobs --jq '
1254+ gh_with_retry run view "$run_id" --json jobs --jq '
12321255 def ts: fromdateiso8601;
12331256 "| Job | Result | Minutes |",
12341257 "| --- | --- | ---: |",
@@ -1245,7 +1268,7 @@ jobs:
12451268 echo
12461269 echo "### Longest queues: ${label}"
12471270 echo
1248- gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/jobs?per_page=100" --jq ".jobs[] | @json" | jq -sr '
1271+ gh_with_retry api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/jobs?per_page=100" --jq ".jobs[] | @json" | jq -sr '
12491272 def ts: fromdateiso8601;
12501273 "| Job | Result | Queue minutes | Run minutes |",
12511274 "| --- | --- | ---: | ---: |",
@@ -1274,7 +1297,7 @@ jobs:
12741297 fi
1275129812761299 local run_json status conclusion artifacts_json
1277- run_json="$(gh run view "$run_id" --json status,conclusion,url,jobs)"
1300+ run_json="$(gh_with_retry run view "$run_id" --json status,conclusion,url,jobs)"
12781301 status="$(jq -r '.status' <<< "$run_json")"
12791302 conclusion="$(jq -r '.conclusion' <<< "$run_json")"
12801303 if [[ "$status" == "completed" && "$conclusion" == "success" ]]; then
@@ -1297,7 +1320,7 @@ jobs:
12971320 echo
12981321 echo "Artifacts:"
12991322 artifacts_json="$(
1300- gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/artifacts?per_page=100" 2>/dev/null || true
1323+ gh_with_retry api "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/artifacts?per_page=100" 2>/dev/null || true
13011324 )"
13021325 if [[ -n "${artifacts_json// }" ]]; then
13031326 jq -r '
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。