No email notification on schedule cron job failure

i added a workflow:
on:
schedule:

  • cron: “* 23 * * *”
    This run on my default branch “master” at the end of every day. When the job fails I am not receiving any email notification as it is running on master branch.

Is it possible to get email notifications on success or failure of my cron job? can I specify my email id in the workflow?

1 Like

Hi @koteswara-kelam,

Github notification will send out the workflow update for watching repository, please check the official doc for the details.

If you’d like to only monitor the specific schedule workflow, you can get existing actions in marketplace and add one in your workflow yaml file.
Code sample as below: send out the email if the workflow failed(use if: failure() expression here, please check doc for the details.)

      - name: failed step
        run: |
          exit 1
      - name: Send mail
        if: failure()
        uses: dawidd6/action-send-mail@v2
        with:
          server_address: smtp.gmail.com
          server_port: 465
          username: ${{secrets.MAIL_USERNAME}}
          password: ${{secrets.MAIL_PASSWORD}}
          subject: Github Actions job result
          # Literal body:
          body: Build job of ${{github.repository}} Failed!
          # Read file contents as body:
          # body: file://README.md
          to: wexxxxx@outlook.com,zxdxxxx5@outlook.com
          from: Github action # <user@example.com>
          # Optional content type (defaults to text/plain):
          # content_type: text/html
          # Optional attachments:
          # attachments: attachments.zip,git.diff,./dist/static/main.js

Please check the answered ticket for your reference.

Thanks.

Ability to notify on scheduled executions (not PR) is critical for making them practical to use.

Apparently these is no native email action that can (re)open a bug on failure, this could be much easier to deal with as it would have the side effect of producing notifications.

Due to potential spam, I think it would be safer to hardcode a specific issue id (tracking issue) which would be reopened/ and commented when scheduled fails. That would be a very useful action to have.

1 Like

That does not seem to actually work – I have it configured to send an email, but when a cronjob just failed, no email was sent.

That seems extremely complicated, now I need to create a new email account and put its password into the GHA configuration somehow? Sorry, but this is not a solution, it’s a work-around. I’d expect a CI service to have some built-in ability to send notifications on failures.

Is GHA really missing this basic functionality that is present in literally every other CI service?

2 Likes

Hi,
We have the same issue as @ralfjung with scheduled jobs. Is this a known issue? We don’t get mail notifications for scheduled jobs, even the notification checkbox is checked. Is github actions aware of this issue? Is there a ticket for this?