Skip to content

Send email on Workflow Run Success/Failure #34982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

NorthRealm
Copy link
Contributor

@NorthRealm NorthRealm commented Jul 7, 2025

Closes #23725

When to send notification: Run Status Done

  • success: Only to trigger user only on notification setting "And Your Own Notifications".
  • failure: Only to trigger user unless "Only Email On Mention" or "Disable Email Notifications".
  • cancelled: Same as on failure.
  • skipped: No notification.

Send to primary email address.

1
2

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 7, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Jul 7, 2025
@NorthRealm
Copy link
Contributor Author

NorthRealm commented Jul 7, 2025

Note: For code reusability, there's a refactor/renaming in mail.go, mail_issue_common.go and mail_test.go in c8b64c7, ed7b2bc

@NorthRealm
Copy link
Contributor Author

1

@lunny lunny added this to the 1.25.0 milestone Jul 7, 2025
@lunny
Copy link
Member

lunny commented Jul 7, 2025

replace #33601

}
}

watchers, err := repo_model.GetRepoWatchers(ctx, repo.ID, db.ListOptionsAll)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a clear definition about "who should receive the emails"

I don't think the "watchers" should receive, for example: on GitHub, I watched some repositories that I have interests, but it doesn't mean that I should receive their notifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I look around but could not find a solid answer, end up asking AI. Send to watchers that are on "And Your Own Notifications"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO:

  • PR poster
  • PR reviewers (maybe)
  • Workflow doer

Copy link
Contributor

@ChristopherHX ChristopherHX Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am writing about an feature opt out, this would affect me on Gitea.com. My local installation cannot deliver E-Mails.
I am a fan of this global user setting of GitHub Actions (https://github.com/settings/notifications)
Screenshot_20250708-105348

Other than that only notify on failure is there as well

Screenshot_20250708-110915
Screenshot_20250708-110416

If I am not mistaken, this would start sending me E-Mails as long I do not opt out anything else.

Reasoning: On GitHub Actions I have multiple daily failures that are not worth a mail.

I read scheduled workflows on GitHub Actions are sent to the last doer changed the cron setting, idk what exactly happens here.
Otherwise I also read this is full of randomness for this trigger

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Gitea currently has no fine-grained control over notification, adding the setting requires a database schema migration.

@wxiaoguang

This comment was marked as resolved.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jul 8, 2025

outdated

And by reading the history discussions:

I think the concern is not addressed? should we send the email on "workflow job" level, or "workflow run" level? (I am not certain about the details, just FYI)


It looks right, the concerns in "Actions - send Email on Success/Failure #33601" should all be addressed. 🙏

@@ -0,0 +1,90 @@
<!DOCTYPE html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think we can try to introduce a "email template review" function in devtest (in the future), then we can preview the email templates. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor mail template and support preview #34990

I think we can use this "mail preview" to help to fine tune mail templates.

(If there is any conflict, I will help to resolve)

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="format-detection" content="telephone=no,date=no,address=no,email=no,url=no">
<title>{{.Subject}}</title>
<style>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the styles look beautiful, but I think we can't use them (well, AI thinks)

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷
1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legacy code. And that style is quite simple, even it doesn't work, the rendered content still looks fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about embedding style into tags? e.g. <div style="...">

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I think it is the only working approach 🤔

(Maybe Refactor mail template and support preview #34990 can help to work on the mail templates.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we can keep this approach. And we can write a helper function to embed these styles to inline (in the future)

@NorthRealm

This comment was marked as resolved.

@wxiaoguang

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Actions - send Email on Success/Failure
5 participants