Skip to content

Commit

Permalink
Fix zulip bot (#892)
Browse files Browse the repository at this point in the history
* Update Zulip Bot to manage image creation run alerts

Signed-off-by: Uday Beswal <[email protected]>

* Add Debugging Steps

Signed-off-by: Uday Beswal <[email protected]>

* Remove Debugging Steps

Signed-off-by: Uday Beswal <[email protected]>

* Add environment

Signed-off-by: Uday Beswal <[email protected]>

* Add Testing Steps

Signed-off-by: Uday Beswal <[email protected]>

* Remove Testing Step

Signed-off-by: Uday Beswal <[email protected]>

---------

Signed-off-by: Uday Beswal <[email protected]>
  • Loading branch information
UdBe authored Nov 6, 2024
1 parent 4f89a20 commit 663c691
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/zulip_notification_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -391,6 +393,7 @@ jobs:
# Save message to summary.txt
echo -e "$message" > summary.txt
cat summary.txt
- name: Send to Zulip
if: ${{ always() }}
Expand All @@ -416,4 +419,4 @@ jobs:
echo "Failed to send message to Zulip."
echo "Response: $response"
exit 1
fi
fi

0 comments on commit 663c691

Please sign in to comment.