We have a scheduled github action that fails sometimes. How can I receive email notifications if it fails. At the moment, only the creator of the workflow receives email notifications when it fails.
We have a scheduled github action that fails sometimes. How can I receive email notifications if it fails. At the moment, only the creator of the workflow receives email notifications when it fails.
You may be looking for this: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#job-status-check-functions
Specifically, if: ${{ failure() }}
you can try this in your actions
- name: Send mail
if: failure()
uses: dawidd6/action-send-mail@v2
with:
# mail server settings
server_address: smtp.gmail.com
server_port: 465
# user credentials
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
# email subject
subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
# email body as text
body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
# comma-separated string, send email to
to: abc@gmail.com,xyz@gmail.com
# from email name
from: XYZ