From 6c8c52ea6a3b8baa56d269fc9fefde852464176a Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Fri, 2 Aug 2024 15:19:35 +0200 Subject: [PATCH] ci: Improve citest_bad script Signed-off-by: Sergei Petrosian --- .github/workflows/tft_citest_bad.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tft_citest_bad.yml b/.github/workflows/tft_citest_bad.yml index 34efe5c..4b65ebb 100644 --- a/.github/workflows/tft_citest_bad.yml +++ b/.github/workflows/tft_citest_bad.yml @@ -29,11 +29,15 @@ jobs: | jq -r "[.workflow_runs[] | select( .display_title == \"$PR_TITLE\") | \ select(.status == \"pending\" or .status == \"queued\" or .status == \"in_progress\") | .id][0]") # if pending run don't exist, take the last run with failure state - if [ "$PENDING_RUN" = "null" ]; then - RUN_ID=$(gh api "repos/$REPO/actions/workflows/tft.yml/runs?event=issue_comment" \ - | jq -r "[.workflow_runs[] | select( .display_title == \"$PR_TITLE\" ) | select( .conclusion == \"failure\" ) | .id][0]") - echo "Re-running workflow $RUN_ID" - gh api --method POST repos/$REPO/actions/runs/$RUN_ID/rerun-failed-jobs - else + if [ "$PENDING_RUN" != "null" ]; then echo "The workflow $PENDING_RUN is still running, wait for it to finish to re-run" + exit 1 fi + RUN_ID=$(gh api "repos/$REPO/actions/workflows/tft.yml/runs?event=issue_comment" \ + | jq -r "[.workflow_runs[] | select( .display_title == \"$PR_TITLE\" ) | select( .conclusion == \"failure\" ) | .id][0]") + if [ "$RUN_ID" = "null" ]; then + echo "Failed workflow not found, exitting" + exit 1 + fi + echo "Re-running workflow $RUN_ID" + gh api --method POST repos/$REPO/actions/runs/$RUN_ID/rerun-failed-jobs