Actions - send Email on Success/Failure #10525

Closed
opened 2025-11-02 09:10:15 -06:00 by GiteaMirror · 23 comments
Owner

Originally created by @ghnp5 on GitHub (Mar 26, 2023).

Feature Description

On GitHub, I get emails every time a run succeeds or fails:

image

In Gitea, even though emails are set up (and working), I'm not getting any emails when a job runs (whether successful or failed).

Would it be possible to be able to set that up?

If that could be a setting in the YAML file, even better!

Thank you very much!

Screenshots

No response

Originally created by @ghnp5 on GitHub (Mar 26, 2023). ### Feature Description On GitHub, I get emails every time a run succeeds or fails: <img width="350" alt="image" src="https://user-images.githubusercontent.com/57591332/227800188-0a12ec9d-cbcb-4564-8f9f-d2474220180d.png"> In Gitea, even though emails are set up (and working), I'm not getting any emails when a job runs (whether successful or failed). Would it be possible to be able to set that up? If that could be a setting in the YAML file, even better! Thank you very much! ### Screenshots _No response_
Author
Owner

@MrHaroldA commented on GitHub (Apr 12, 2023):

I would like a more general 'event driven messaging system', as I also would like to get an email when a pull request is created, or when a pull request results in a merge conflict.

@MrHaroldA commented on GitHub (Apr 12, 2023): I would like a more general 'event driven messaging system', as I also would like to get an email when a pull request is created, or when a pull request results in a merge conflict.
Author
Owner

@GammaGames commented on GitHub (Aug 24, 2023):

I needed notifications for job failures so I added this step to most of my workflows:

- name: Send mail
    if: failure()
    uses: https://github.com/dawidd6/action-send-mail@v3
    with:
        to: ${{ secrets.MAIL_TO }}
        from: Gitea <gitea@hostname>
        subject: ${{ gitea.repository }} ${{gitea.workflow}} ${{ job.status }}
        priority: high
        convert_markdown: true
        html_body: |
            ### Job ${{ job.status }}

            ${{ github.repository }}: [${{ github.ref }}@${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions)

I tried to create a link to the failed action by adding runs/${{ github.run_id }} to the url, but it didn't work

Edit: I also wasn't able to include the previous step's output in the message body. If anyone can figure that out, please share!

@GammaGames commented on GitHub (Aug 24, 2023): I needed notifications for job failures so I added this step to most of my workflows: ```yaml - name: Send mail if: failure() uses: https://github.com/dawidd6/action-send-mail@v3 with: to: ${{ secrets.MAIL_TO }} from: Gitea <gitea@hostname> subject: ${{ gitea.repository }} ${{gitea.workflow}} ${{ job.status }} priority: high convert_markdown: true html_body: | ### Job ${{ job.status }} ${{ github.repository }}: [${{ github.ref }}@${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions) ``` I tried to create a link to the failed action by adding `runs/${{ github.run_id }}` to the url, but it didn't work Edit: I also wasn't able to include the previous step's output in the message body. If anyone can figure that out, please share!
Author
Owner

@ghnp5 commented on GitHub (Aug 24, 2023):

Thanks @GammaGames

How do you make it run this only at the end of the workflow, whether it was successful or failed?

If we don't make it dependent, it might run in parallel with the rest, but if we make it dependent, then only if everything else succeeds, the email will be sent.

Also, "success()", "failure()", etc, seem to be per Job, and not per Action/Workflow.

Or am I missing something? :)

Thank you!

@ghnp5 commented on GitHub (Aug 24, 2023): Thanks @GammaGames How do you make it run this only at the end of the workflow, whether it was successful or failed? If we don't make it dependent, it might run in parallel with the rest, but if we make it dependent, then only if everything else succeeds, the email will be sent. Also, "success()", "failure()", etc, seem to be per Job, and not per Action/Workflow. Or am I missing something? :) Thank you!
Author
Owner

@GammaGames commented on GitHub (Aug 24, 2023):

How do you make it run this only at the end of the workflow, whether it was successful or failed?

You'd want to replace the if: failure() with if: always() (or if: !cancelled()). I always have the step last in my jobs

Also, "success()", "failure()", etc, seem to be per Job, and not per Action/Workflow.

According to the docs failure():

Returns true when any previous step of a job fails. If you have a chain of dependent jobs, failure() returns true if any ancestor job fails.

You might be able to set up a dependent job so you only have to add notification step once per workflow. So far my workflows have been relatively simple, so I haven't had the need to experiment with that

@GammaGames commented on GitHub (Aug 24, 2023): > How do you make it run this only at the end of the workflow, whether it was successful or failed? You'd want to replace the [`if: failure()`](https://docs.github.com/en/actions/learn-github-actions/expressions#failure) with [`if: always()`](https://docs.github.com/en/actions/learn-github-actions/expressions#always) (or `if: !cancelled()`). I always have the step last in my jobs > Also, "success()", "failure()", etc, seem to be per Job, and not per Action/Workflow. According to the docs `failure()`: > Returns true when any previous step of a job fails. If you have a chain of dependent jobs, failure() returns true if any ancestor job fails. You might be able to set up a [dependent job](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-not-requiring-successful-dependent-jobs) so you only have to add notification step once per workflow. So far my workflows have been relatively simple, so I haven't had the need to experiment with that
Author
Owner

@ghnp5 commented on GitHub (Aug 24, 2023):

Hey

Thank you for the answers.

Yeah, failure() is true when any previous step of a job fails.

That's my problem. I have complex workflows with several jobs (using matrix strategy, etc), dependent on each other, etc...

So, I can't have a "final job" where I'd put if: failure(), because that simply won't run if any of the previous jobs of the workflow failed.

I believe the only way to get what I want is by Gitea implementing notifications for whether Actions have succeeded or failed.

@ghnp5 commented on GitHub (Aug 24, 2023): Hey Thank you for the answers. Yeah, `failure()` is true when any **previous step** of **a job** fails. That's my problem. I have complex workflows with several jobs (using matrix strategy, etc), dependent on each other, etc... So, I can't have a "final job" where I'd put `if: failure()`, because that simply won't run if any of the previous jobs of the workflow failed. I believe the only way to get what I want is by Gitea implementing notifications for whether Actions have succeeded or failed.
Author
Owner

@GammaGames commented on GitHub (Aug 24, 2023):

I believe you are correct, having built-in notifications would be the best solution anyway. But for anyone else with simple workflows, my solution might work for now!

@GammaGames commented on GitHub (Aug 24, 2023): I believe you are correct, having built-in notifications would be the best solution anyway. But for anyone else with simple workflows, my solution might work for now!
Author
Owner
@silverwind commented on GitHub (Sep 21, 2023): Should be a per-user setting to get notified only for their own pushes: https://docs.github.com/en/account-and-profile/managing-subscriptions-and-notifications-on-github/setting-up-notifications/configuring-notifications#github-actions-notification-options ![image](https://github.com/go-gitea/gitea/assets/115237/ca9f8b7f-e839-4221-b7d0-d42e923e5423)
Author
Owner

@Xulunix commented on GitHub (Apr 4, 2024):

Any progress on this?
Considering that we still need a workaround to get the users email address in order to send notifications from within the action,
a proper notification system would greatly improve the value and usability of actions.

@Xulunix commented on GitHub (Apr 4, 2024): Any progress on this? Considering that we still need a [workaround ](https://github.com/go-gitea/gitea/issues/27133#issuecomment-1785636494)to get the users email address in order to send notifications from within the action, a proper notification system would greatly improve the value and usability of actions.
Author
Owner

@silverwind commented on GitHub (Apr 5, 2024):

If the pusher's email address is made easily available to the action, it shouldn't be too hard to write a action that sends the actual mail, I assume. That should bridge us over until a proper notification system is in place.

@silverwind commented on GitHub (Apr 5, 2024): If the pusher's email address is made easily available to the action, it shouldn't be too hard to write a action that sends the actual mail, I assume. That should bridge us over until a proper notification system is in place.
Author
Owner

@maxant commented on GitHub (Nov 6, 2024):

This could work, for sending an email to the user who broke the build:

  1. add a step at the end of the job

    • name: OnFailure
      if: ${{ failure() }}
      env:
      PUSHER_ID: "${{ gitea.event.pusher.id }}"
      PUSHER_EMAIL: "${{ gitea.event.pusher.email }}"
      run: echo FAILED $PUSHER_ID $PUSHER_EMAIL

that prints FAILED 2 ant@noreply.localhost in my case. since I don't allow email addresses to be public.

  1. extend that, to use the ID and curl to access the email address of the user:

curl -X 'GET'
'https://git.yourdomain.com/api/v1/admin/emails'
-H 'accept: application/json'
-H 'authorization: Basic xyz' \ <<<< needs to be for an admin user
| jq ...

  1. extend it again to send mail using your favorite bash method, e.g. with ssmtp
@maxant commented on GitHub (Nov 6, 2024): This could work, for sending an email to the user who broke the build: 1) add a step at the end of the job - name: OnFailure if: ${{ failure() }} env: PUSHER_ID: "${{ gitea.event.pusher.id }}" PUSHER_EMAIL: "${{ gitea.event.pusher.email }}" run: echo FAILED $PUSHER_ID $PUSHER_EMAIL that prints `FAILED 2 ant@noreply.localhost` in my case. since I don't allow email addresses to be public. 2) extend that, to use the ID and curl to access the email address of the user: curl -X 'GET' \ 'https://git.yourdomain.com/api/v1/admin/emails' \ -H 'accept: application/json' \ -H 'authorization: Basic xyz' \ <<<< needs to be for an admin user | jq ... 3) extend it again to send mail using your favorite bash method, e.g. with ssmtp
Author
Owner

@algora-pbc[bot] commented on GitHub (Dec 21, 2024):

💎 $50 bounty • Frank Villaro-Dixon

💎 $20 bounty • Sascha Simon

💎 $10 bounty • nf_algora

💎 $25 bounty • Günter

Steps to solve:

  1. Start working: Comment /attempt #23725 with your implementation plan
  2. Submit work: Create a pull request including /claim #23725 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to go-gitea/gitea!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @mehul-m-prajapati Dec 21, 2024, 6:56:05 PM WIP
🔴 @Mayank77maruti Feb 14, 2025, 8:21:52 AM #33601
@algora-pbc[bot] commented on GitHub (Dec 21, 2024): ## 💎 $50 bounty [• Frank Villaro-Dixon](https://console.algora.io/org/Frankkkkk) ## 💎 $20 bounty [• Sascha Simon](https://console.algora.io/org/inexcitus) ## 💎 $10 bounty [• nf_algora](https://console.algora.io/org/nf_algora) ## 💎 $25 bounty [• Günter](https://console.algora.io/org/lifeofguenter) ### Steps to solve: 1. **Start working**: Comment `/attempt #23725` with your implementation plan 2. **Submit work**: Create a pull request including `/claim #23725` in the PR body to claim the bounty 3. **Receive payment**: 100% of the bounty is received 2-5 days post-reward. [Make sure you are eligible for payouts](https://docs.algora.io/bounties/payments#supported-countries-regions) Thank you for contributing to go-gitea/gitea! **[Add a bounty](https://console.algora.io/org/Frankkkkk/bounties/community?fund=go-gitea%2Fgitea%2323725)** • **[Share on socials](https://twitter.com/intent/tweet?text=%24105+bounty%21+%F0%9F%92%8E+https%3A%2F%2Fgithub.com%2Fgo-gitea%2Fgitea%2Fissues%2F23725&related=algoraio)** <table> <thead> <tr> <th>Attempt</th> <th>Started (GMT+0)</th> <th>Solution</th> </tr> </thead> <tbody> <tr> <td>🟢 @mehul-m-prajapati</td> <td>Dec 21, 2024, 6:56:05 PM</td> <td>WIP</td> </tr> <tr> <td>🔴 @Mayank77maruti</td> <td>Feb 14, 2025, 8:21:52 AM</td> <td><a href="https://github.com/go-gitea/gitea/pull/33601">#33601</a></td> </tr> </tbody> </table>
Author
Owner

@mehul-m-prajapati commented on GitHub (Dec 21, 2024):

/attempt #23725

Algora profile Completed bounties Tech Active attempts Options
@mehul-m-prajapati 3 bounties from 1 project
TypeScript, JavaScript,
HTML & more
Cancel attempt
@mehul-m-prajapati commented on GitHub (Dec 21, 2024): /attempt #23725 <div id="algora-attempt" /> | [Algora profile](https://console.algora.io/@/mehul-m-prajapati) | Completed bounties | Tech | Active attempts | Options | | --- | --- | --- | --- | --- | | @mehul-m-prajapati | 3 bounties from 1 project | <div align="center">TypeScript, JavaScript, <br />HTML & more</div> | <div align="center"></div> | [Cancel attempt](https://console.algora.io/api/bounties/cm4y73hnr0002l703gnk6dink/cancel-attempt) |
Author
Owner

@steadfasterX commented on GitHub (Jan 24, 2025):

will this also cover action events via webhooks? so one can send to matrix, telegram etc when an action fails? I hate mails ;)

@steadfasterX commented on GitHub (Jan 24, 2025): will this also cover action events via webhooks? so one can send to matrix, telegram etc when an action fails? I hate mails ;)
Author
Owner

@lunny commented on GitHub (Jan 24, 2025):

will this also cover action events via webhooks? so one can send to matrix, telegram etc when an action fails? I hate mails ;)

They should be triggered by the same event.

@lunny commented on GitHub (Jan 24, 2025): > will this also cover action events via webhooks? so one can send to matrix, telegram etc when an action fails? I hate mails ;) They should be triggered by the same event.
Author
Owner

@Mayank77maruti commented on GitHub (Feb 14, 2025):

/attempt #23725

Algora profile Completed bounties Tech Active attempts Options
@Mayank77maruti 1 bounty from 1 project
CSS, Python,
JavaScript & more
Cancel attempt
@Mayank77maruti commented on GitHub (Feb 14, 2025): /attempt #23725 <div id="algora-attempt" /> | [Algora profile](https://console.algora.io/@/Mayank77maruti) | Completed bounties | Tech | Active attempts | Options | | --- | --- | --- | --- | --- | | @Mayank77maruti | 1 bounty from 1 project | <div align="center">CSS, Python, <br />JavaScript & more</div> | <div align="center"></div> | [Cancel attempt](https://console.algora.io/api/bounties/cm4y73hnr0002l703gnk6dink/cancel-attempt) |
Author
Owner

@luffy-orf commented on GitHub (May 25, 2025):

/attempt #23725

@luffy-orf commented on GitHub (May 25, 2025): /attempt #23725
Author
Owner

@ghnp5 commented on GitHub (May 25, 2025):

Hey! Whoever worked on the 2 PRs above, thanks for that!

We really need this feature merged ASAP !! :-)

@ghnp5 commented on GitHub (May 25, 2025): Hey! Whoever worked on the 2 PRs above, thanks for that! We really need this feature merged ASAP !! :-)
Author
Owner
@ghnp5 commented on GitHub (May 25, 2025): https://github.com/go-gitea/gitea/pull/33601 https://github.com/go-gitea/gitea/pull/34532
Author
Owner

@NorthRealm commented on GitHub (Jul 11, 2025):

/attempt #23725

@NorthRealm commented on GitHub (Jul 11, 2025): /attempt #23725
Author
Owner

@algora-pbc[bot] commented on GitHub (Jul 16, 2025):

🎉 The pull request of @NorthRealm has been merged. The bounty can be rewarded here

cc @lifeofguenter, @, @, @Frankkkkk

@algora-pbc[bot] commented on GitHub (Jul 16, 2025): 🎉 The pull request of @NorthRealm has been merged. The bounty can be rewarded [here](https://algora.io/claims/DRMkWmMg7oC6kuNg) cc @lifeofguenter, @, @, @Frankkkkk
Author
Owner

@algora-pbc[bot] commented on GitHub (Jul 16, 2025):

@NorthRealm: You've been awarded a $20 by Sascha Simon! 👉 Complete your Algora onboarding to collect the bounty.

@algora-pbc[bot] commented on GitHub (Jul 16, 2025): @NorthRealm: You've been awarded a **$20** by **Sascha Simon**! 👉 [Complete your Algora onboarding](https://algora.io/onboarding/dev) to collect the bounty.
Author
Owner

@ghnp5 commented on GitHub (Jul 16, 2025):

Thank you so much for this!! 🥳🎉🧡

@ghnp5 commented on GitHub (Jul 16, 2025): Thank you so much for this!! 🥳🎉🧡
Author
Owner

@algora-pbc[bot] commented on GitHub (Jul 19, 2025):

@NorthRealm: You've been awarded a $50 by Frank! 👉 Complete your Algora onboarding to collect the bounty.

@algora-pbc[bot] commented on GitHub (Jul 19, 2025): @NorthRealm: You've been awarded a **$50** by **Frank**! 👉 [Complete your Algora onboarding](https://algora.io/onboarding/dev) to collect the bounty.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10525