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.