|
32 | 32 | with: |
33 | 33 | node-version: ${{ env.NODE_VERSION }} |
34 | 34 | 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