github actions: notifications on workflow failure

Viewed 9725

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.

my settings

2 Answers

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
Related