Skip if jobs are still running

This commit is contained in:
Lup Yuen Lee 2024-10-28 20:48:15 +08:00
parent 76d312c2ef
commit 8f1a14bcf4

View file

@ -6,10 +6,36 @@ for (( ; ; )); do
nuttxpr/nuttx \
nuttxpr/nuttx-apps
do
## Find the latest failed job for today
## Find the running jobs for today
echo repo=$repo
date=$(date -u +'%Y-%m-%d')
run_list="
running_list="
$(gh run list \
--repo $repo \
--limit 1 \
--created $date \
--status queued \
--json databaseId,name,displayTitle,conclusion \
--jq '.[].databaseId')
$(gh run list \
--repo $repo \
--limit 1 \
--created $date \
--status in_progress \
--json databaseId,name,displayTitle,conclusion \
--jq '.[].databaseId')
"
running_list=$(echo $running_list | xargs)
echo running_list=$running_list
## Skip if jobs are still running
if [[ "$running_list" != "" ]]; then
echo Skipping $repo, jobs are still running
continue
fi
## Find the latest failed job for today
failed_list="
$(gh run list \
--repo $repo \
--limit 1 \
@ -18,9 +44,10 @@ for (( ; ; )); do
--json databaseId,name,displayTitle,conclusion \
--jq '.[].databaseId')
"
## Restart the failed job
echo run_list=$run_list
for run_id in $run_list; do
echo failed_list=$failed_list
for run_id in $failed_list; do
echo Restarting $run_id
gh run rerun --repo $repo --debug --failed $run_id
done