



















@@ -301,6 +301,14 @@ jobs:
301301 echo "Dispatched ${workflow}: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
302302 echo "run_id=${run_id}" >> "$GITHUB_OUTPUT"
303303304+ fetch_child_run_json() {
305+ gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
306+ }
307+308+ fetch_child_jobs() {
309+ gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/jobs?per_page=100" --jq '.jobs[]'
310+ }
311+304312 cancel_child() {
305313 if [[ -n "${run_id:-}" ]]; then
306314 echo "Cancelling child workflow ${workflow}: ${run_id}" >&2
@@ -311,26 +319,26 @@ jobs:
311319312320 poll_count=0
313321 while true; do
314- status="$(gh run view "$run_id" --json status --jq '.status')"
322+ status="$(fetch_child_run_json | jq -r '.status')"
315323 if [[ "$status" == "completed" ]]; then
316324 break
317325 fi
318326 poll_count=$((poll_count + 1))
319327 if (( poll_count % 10 == 0 )); then
320328 echo "Still waiting on ${workflow}: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
321- gh run view "$run_id" --json jobs --jq '.jobs[] | select(.status != "completed") | {name, status, url}' || true
329+ fetch_child_jobs | jq 'select(.status != "completed") | {name, status, url: .html_url}' || true
322330 fi
323331 sleep 30
324332 done
325333 trap - EXIT INT TERM
326334327- conclusion="$(gh run view "$run_id" --json conclusion --jq '.conclusion')"
328- url="$(gh run view "$run_id" --json url --jq '.url')"
335+ conclusion="$(fetch_child_run_json | jq -r '.conclusion // ""')"
336+ url="$(fetch_child_run_json | jq -r '.html_url')"
329337 echo "${workflow} finished with ${conclusion}: ${url}"
330338 echo "url=${url}" >> "$GITHUB_OUTPUT"
331339 echo "conclusion=${conclusion}" >> "$GITHUB_OUTPUT"
332340 if [[ "$conclusion" != "success" ]]; then
333- gh run view "$run_id" --json jobs --jq '.jobs[] | select(.conclusion != "success" and .conclusion != "skipped") | {name, conclusion, url}' || true
341+ fetch_child_jobs | jq 'select(.conclusion != "success" and .conclusion != "skipped") | {name, conclusion, url: .html_url}' || true
334342 exit 1
335343 fi
336344 }
@@ -401,6 +409,14 @@ jobs:
401409 echo "Dispatched ${workflow}: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
402410 echo "run_id=${run_id}" >> "$GITHUB_OUTPUT"
403411412+ fetch_child_run_json() {
413+ gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
414+ }
415+416+ fetch_child_jobs() {
417+ gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/jobs?per_page=100" --jq '.jobs[]'
418+ }
419+404420 cancel_child() {
405421 if [[ -n "${run_id:-}" ]]; then
406422 echo "Cancelling child workflow ${workflow}: ${run_id}" >&2
@@ -411,26 +427,26 @@ jobs:
411427412428 poll_count=0
413429 while true; do
414- status="$(gh run view "$run_id" --json status --jq '.status')"
430+ status="$(fetch_child_run_json | jq -r '.status')"
415431 if [[ "$status" == "completed" ]]; then
416432 break
417433 fi
418434 poll_count=$((poll_count + 1))
419435 if (( poll_count % 10 == 0 )); then
420436 echo "Still waiting on ${workflow}: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
421- gh run view "$run_id" --json jobs --jq '.jobs[] | select(.status != "completed") | {name, status, url}' || true
437+ fetch_child_jobs | jq 'select(.status != "completed") | {name, status, url: .html_url}' || true
422438 fi
423439 sleep 30
424440 done
425441 trap - EXIT INT TERM
426442427- conclusion="$(gh run view "$run_id" --json conclusion --jq '.conclusion')"
428- url="$(gh run view "$run_id" --json url --jq '.url')"
443+ conclusion="$(fetch_child_run_json | jq -r '.conclusion // ""')"
444+ url="$(fetch_child_run_json | jq -r '.html_url')"
429445 echo "${workflow} finished with ${conclusion}: ${url}"
430446 echo "url=${url}" >> "$GITHUB_OUTPUT"
431447 echo "conclusion=${conclusion}" >> "$GITHUB_OUTPUT"
432448 if [[ "$conclusion" != "success" ]]; then
433- gh run view "$run_id" --json jobs --jq '.jobs[] | select(.conclusion != "success" and .conclusion != "skipped") | {name, conclusion, url}' || true
449+ fetch_child_jobs | jq 'select(.conclusion != "success" and .conclusion != "skipped") | {name, conclusion, url: .html_url}' || true
434450 exit 1
435451 fi
436452 }
@@ -511,6 +527,14 @@ jobs:
511527 echo "Dispatched ${workflow}: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
512528 echo "run_id=${run_id}" >> "$GITHUB_OUTPUT"
513529530+ fetch_child_run_json() {
531+ gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
532+ }
533+534+ fetch_child_jobs() {
535+ gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/jobs?per_page=100" --jq '.jobs[]'
536+ }
537+514538 release_check_blocking_job() {
515539 case "$1" in
516540 "resolve_target" | \
@@ -561,20 +585,25 @@ jobs:
561585562586 poll_count=0
563587 while true; do
564- status="$(gh run view "$run_id" --json status --jq '.status')"
588+ status="$(fetch_child_run_json | jq -r '.status')"
565589 if [[ "$status" == "completed" ]]; then
566590 break
567591 fi
568592 poll_count=$((poll_count + 1))
569593 if (( poll_count % 10 == 0 )); then
570594 echo "Still waiting on ${workflow}: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
571- gh run view "$run_id" --json jobs --jq '.jobs[] | select(.status != "completed") | {name, status, url}' || true
595+ fetch_child_jobs | jq 'select(.status != "completed") | {name, status, url: .html_url}' || true
572596 fi
573597 sleep 30
574598 done
575599 trap - EXIT INT TERM
576600577- run_json="$(gh run view "$run_id" --json conclusion,url,jobs)"
601+ jobs_json="$(fetch_child_jobs | jq -s '{jobs: [.[] | {name, conclusion, url: .html_url}]}')"
602+ run_json="$(
603+ jq -s '.[0] + .[1]' \
604+ <(fetch_child_run_json | jq '{conclusion: (.conclusion // ""), url: .html_url}') \
605+ <(printf '%s\n' "$jobs_json")
606+ )"
578607 conclusion="$(jq -r '.conclusion' <<< "$run_json")"
579608 url="$(jq -r '.url' <<< "$run_json")"
580609 echo "${workflow} finished with ${conclusion}: ${url}"
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。