Skip to content

Commit 99f8145

Browse files
authored
Add GChat notifications when image push failures occur (#376)
1 parent dd4ea39 commit 99f8145

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

.github/workflows/cnf-test-partner-image.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,15 @@ jobs:
8080
push: true
8181
file: ${{ env.IMAGE_CONTAINER_FILE_PATH }}
8282
tags: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SPECIFIC_IMAGE_TAG }}'
83+
84+
- name: If failed to create the image, send alert msg to dev team.
85+
if: ${{ failure() }}
86+
env:
87+
COMMIT_SHA: ${{ github.sha }}
88+
JOB_RUN_ID: ${{ github.run_id }}
89+
JOB_RUN_ATTEMPT: ${{ github.run_attempt }}
90+
GITHUB_REPO: 'https://github.com/${{ github.repository }}'
91+
run: |
92+
curl -X POST --data "{
93+
\"text\": \"🚨⚠️ Failed to create partner image version \`$IMAGE_TAG\` from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \"
94+
}" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.GCHAT_WEBHOOK_URL }}'

.github/workflows/debug-partner-image.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,15 @@ jobs:
9090
file: ${{ env.IMAGE_CONTAINER_FILE_PATH }}
9191
tags: ${{ steps.meta.outputs.tags }}
9292
labels: ${{ steps.meta.outputs.labels }}
93+
94+
- name: If failed to create the image, send alert msg to dev team.
95+
if: ${{ failure() }}
96+
env:
97+
COMMIT_SHA: ${{ github.sha }}
98+
JOB_RUN_ID: ${{ github.run_id }}
99+
JOB_RUN_ATTEMPT: ${{ github.run_attempt }}
100+
GITHUB_REPO: 'https://github.com/${{ github.repository }}'
101+
run: |
102+
curl -X POST --data "{
103+
\"text\": \"🚨⚠️ Failed to create debug parter image version \`$IMAGE_TAG\` from commit \<$GITHUB_REPO/commit/$COMMIT_SHA|$COMMIT_SHA\>, job ID \<$GITHUB_REPO/actions/runs/$JOB_RUN_ID/attempts/$JOB_RUN_ATTEMPT|$JOB_RUN_ID\> \"
104+
}" -H 'Content-type: application/json; charset=UTF-8' '${{ secrets.GCHAT_WEBHOOK_URL }}'

0 commit comments

Comments
 (0)