Skip to content

Commit 443715a

Browse files
authored
Merge pull request #68 from layer5io/leecalcote-patch-6
Implement email notification on job failure
2 parents d7b9300 + a01143c commit 443715a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/multi-platform.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,34 @@ jobs:
116116
password: ${{ secrets.DOCKER_PASSWORD }}
117117
repository: layer5/kanvas-docker-extension
118118
readme-filepath: README.md
119+
120+
email-on-failure:
121+
needs: [docker-build]
122+
if: ${{ failure() }}
123+
runs-on: ubuntu-24.04
124+
steps:
125+
- name: Find failed jobs.
126+
run: |
127+
curl "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq -r '.jobs[] | select(.conclusion == "failure") | "\(.name): \(.steps[] | select(.conclusion == "failure") | .name)\n\(.html_url)\n"' >> output.txt
128+
# Save multi-line environment variables by using the delimiters syntex.
129+
echo "EMAIL_BODY<<EOF" >> $GITHUB_ENV
130+
echo "$(cat ./output.txt)" >> $GITHUB_ENV
131+
echo "EOF" >> $GITHUB_ENV
132+
- name: Failed jobs summary
133+
run: |
134+
echo "${{ env.EMAIL_BODY }}"
135+
- name: Send Email Notification
136+
if: env.EMAIL_BODY != ''
137+
uses: dawidd6/action-send-mail@v6
138+
with:
139+
server_address: smtp.gmail.com
140+
server_port: 465
141+
username: ${{ secrets.MAIL_USERNAME }}
142+
password: ${{ secrets.MAIL_PASSWORD }}
143+
subject: Job(s) failure in the build-and-release-stable workflow
144+
to: support@layer5.io
145+
from: Docker Kanvas Extension Releaser
146+
body: |
147+
The workflow failed. Here are the details:
148+
${{ env.EMAIL_BODY }}
149+
Workflow run log URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 commit comments

Comments
 (0)