Skip to content

Commit 8bc3e4e

Browse files
authored
Merge pull request #86 from janithjay/add-e2e-nightly-chat-notification
Send a Google Chat notification when nightly E2E fails
2 parents cd30859 + cc12c4e commit 8bc3e4e

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

‎.github/workflows/e2e-nightly.yml‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,64 @@ jobs:
3232
with:
3333
node-version: ${{ env.NODE_VERSION }}
3434
artifact-name: playwright-report-nightly
35+
36+
# Google Chat step - each failure posts as its own independent message.
37+
- name: 🔔 Send Google Chat Notification on Failure
38+
if: failure()
39+
shell: bash
40+
env:
41+
GOOGLE_CHAT_WEBHOOK: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
42+
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
43+
RUN_NUMBER: ${{ github.run_number }}
44+
COMMIT: ${{ github.sha }}
45+
run: |
46+
if [ -z "$GOOGLE_CHAT_WEBHOOK" ]; then
47+
echo "GOOGLE_CHAT_WEBHOOK secret is not set. Skipping Google Chat notification."
48+
exit 0
49+
fi
50+
51+
FAILURE_DATE=$(date -u +"%d-%m-%Y")
52+
53+
jq -n \
54+
--arg run_number "$RUN_NUMBER" \
55+
--arg commit "${COMMIT:0:8}" \
56+
--arg workflow_url "$WORKFLOW_URL" \
57+
--arg failure_date "$FAILURE_DATE" \
58+
'{
59+
"cards": [{
60+
"header": {
61+
"title": "🔴 JavaScript SDKs E2E Failed",
62+
"subtitle": ("Nightly - " + $failure_date),
63+
"imageUrl": "https://raw.githubusercontent.com/github/explore/main/topics/javascript/javascript.png",
64+
"imageStyle": "AVATAR"
65+
},
66+
"sections": [
67+
{
68+
"widgets": [
69+
{"keyValue": {"topLabel": "Run", "content": ("#" + $run_number)}},
70+
{"keyValue": {"topLabel": "Commit", "content": $commit}}
71+
]
72+
},
73+
{
74+
"widgets": [
75+
{
76+
"buttons": [
77+
{
78+
"textButton": {
79+
"text": "VIEW WORKFLOW RUN",
80+
"onClick": {"openLink": {"url": $workflow_url}}
81+
}
82+
}
83+
]
84+
}
85+
]
86+
}
87+
]
88+
}]
89+
}' > payload.json
90+
91+
if curl -f -X POST -H "Content-Type: application/json" -d @payload.json "$GOOGLE_CHAT_WEBHOOK"; then
92+
echo "✅ Google Chat notification sent successfully"
93+
else
94+
echo "⚠️ Failed to send Google Chat notification"
95+
fi

0 commit comments

Comments
 (0)