From 663c691615bffd9f91476ba99e07f28d7cdb4d9f Mon Sep 17 00:00:00 2001 From: Uday Beswal <71140717+UdBe@users.noreply.github.com> Date: Wed, 6 Nov 2024 20:48:10 +0530 Subject: [PATCH] Fix zulip bot (#892) * Update Zulip Bot to manage image creation run alerts Signed-off-by: Uday Beswal * Add Debugging Steps Signed-off-by: Uday Beswal * Remove Debugging Steps Signed-off-by: Uday Beswal * Add environment Signed-off-by: Uday Beswal * Add Testing Steps Signed-off-by: Uday Beswal * Remove Testing Step Signed-off-by: Uday Beswal --------- Signed-off-by: Uday Beswal --- .github/workflows/zulip_notification_bot.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/zulip_notification_bot.yml b/.github/workflows/zulip_notification_bot.yml index f5b97ed7c2..890477710c 100644 --- a/.github/workflows/zulip_notification_bot.yml +++ b/.github/workflows/zulip_notification_bot.yml @@ -164,6 +164,7 @@ jobs: image_creation_run_alerts: name: Image Creation Run Alerts runs-on: ubuntu-latest + environment: actions-cicd steps: - name: Get the last two runs of Image Creation Run workflow @@ -191,16 +192,17 @@ jobs: } const workflow_id = workflow.id; - // Get the last two workflow runs const runsResponse = await github.rest.actions.listWorkflowRuns({ owner, repo, workflow_id, - per_page: 2, + status: 'completed', + per_page: 10, }); const runs = runsResponse.data.workflow_runs; + if (runs.length < 2) { - core.setFailed('Not enough workflow runs found.'); + core.setFailed('Not enough completed workflow runs found.'); return; } @@ -364,7 +366,7 @@ jobs: # Process jobs with '-ib' suffix if [[ -n "$failed_jobs_ib" ]]; then - message+="**Ironbank Images failed consecutively in last two runs**:\n" + message+="\n**Ironbank Images failing consecutively in last two runs**:\n" count=1 IFS=',' read -ra JOBS_IB <<< "$failed_jobs_ib" for job in "${JOBS_IB[@]}"; do @@ -375,7 +377,7 @@ jobs: # Process jobs without '-ib' suffix if [[ -n "$failed_jobs_no_ib" ]]; then - message+="\n**Non-Ironbank Images failed consecutively in last two runs**:\n" + message+="\n\n**Non-Ironbank Images failing consecutively in last two runs**:\n" count=1 IFS=',' read -ra JOBS_NO_IB <<< "$failed_jobs_no_ib" for job in "${JOBS_NO_IB[@]}"; do @@ -391,6 +393,7 @@ jobs: # Save message to summary.txt echo -e "$message" > summary.txt + cat summary.txt - name: Send to Zulip if: ${{ always() }} @@ -416,4 +419,4 @@ jobs: echo "Failed to send message to Zulip." echo "Response: $response" exit 1 - fi + fi \ No newline at end of file