Skip to content

Instantly share code, notes, and snippets.

@ldez
Last active November 28, 2024 21:41
Show Gist options
  • Save ldez/bd6e6401ad0855e6c0de6da19a8c50b5 to your computer and use it in GitHub Desktop.
Save ldez/bd6e6401ad0855e6c0de6da19a8c50b5 to your computer and use it in GitHub Desktop.
Gmail and GitHub - Filters

Gmail and GitHub

How to filter emails from GitHub in Gmail and flag them with labels.

The labels in this document are just examples.

Pull Request

Filter Label
from:(notifications@github.com) subject:"PR \#" gh-pull-request

Note: special characters like ( or # are ignored and the escape \ doesn't work.

GitHub Actions

Filter Label
from:(ci_activity@github.com) gha

Discussion

Filter Label
from:(notifications@github.com) subject:"\(Discussion \#) gh-discussion

Releases

Filter Label
from:(notifications@github.com) "Visit the release page to download them." gh-relases

Assignments

Filter Label
from:(notifications@github.com) cc:(assign@noreply.github.com) gh-assignments

Mentions

Filter Label
from:(notifications@github.com) cc:(mention@noreply.github.com) gh-mentions

Review Requested

Filter Label
from:(notifications@github.com) cc:(review_requested@noreply.github.com) "requested your review on" gh-review-requested

GitHub emails

  • subscribed: The notification arrived because you’re watching the repository.
  • manual: The notification arrived because you’ve specifically decided to subscribe to the thread (via an Issue or Pull Request).
  • author: The notification arrived because you’ve created the thread.
  • comment: The notification arrived because you’ve commented on the thread.
  • mention: The notification arrived because you were specifically @mentioned in the content.
  • team_mention: The notification arrived because you were on a team that was mentioned (like @org/team).
  • state_change: The notification arrived because you changed the thread state (like closing an Issue or merging a Pull Request).
  • assign: The notification arrived because you were assigned to the Issue.
  • review_requested: The notification arrived because your review is required.
  • ci_activity: The notification arrived because CI activities (failure, success, ...)
  • push: The notification arrived because of a push

example:

Approximate rules

WARNING: Those rules can produce false-positives.

Closed (~)

label: gh-closed

Filter:

from:(notifications@github.com) "Closed \#"

Note: special characters like ( or # are ignored and the escape \ doesn't work.

Merged (~)

label: gh-merged

Filter:

from:(notifications@github.com) "Merged \#"

Note: special characters like ( or # are ignored and the escape \ doesn't work.

Issue (~)

label: gh-issue

Filter:

from:(notifications@github.com) subject:("Issue \#" -"PR \#")

Note: special characters like ( or # are ignored and the escape \ doesn't work.

References

@lizozom
Copy link

lizozom commented Apr 14, 2019

Great work. Implemented in my own gmail setup :)

@insipx
Copy link

insipx commented Apr 19, 2019

Awesome! This should make github notifications much easier to deal with in my email.

Also, keep in mind you can keep multiple Emails in Github and assign different emails to receive notifications based on a Github Organization. Useful if you like to alias multiple emails to handle different categories of mail

@insipx
Copy link

insipx commented Jul 31, 2019

Anyone know if there is a good way to filter for releases only?

@fatmcgav
Copy link

Note that it's possible to get "false positives" on the Merged search above...

Using from:(notifications@github.com) "merged AROUND 1 into" gives better results :)

@EasyAsABC123
Copy link

EasyAsABC123 commented Sep 26, 2019

Perhaps utilizing regex instead of hardcoding numbers? Example: from:(notifications@github.com) AND {"Patch Links" "approved this pull request." "requested changes on this pull request." "commented on this pull request." "pushed /d+ commit."}

@tmandry
Copy link

tmandry commented Dec 17, 2020

You can't use regex in gmail filters, but you can use the AROUND operator. This works for me:

{"pushed AROUND 1 commit" "pushed AROUND 1 commits"}

@johnkord
Copy link

johnkord commented Oct 8, 2021

To filter out GitHub Code Owners review requests (as part of a group/team) but still find review requests in which my GitHub username is explicitly added, I used this search expression:
from:(notifications@github.com) cc:(review_requested@noreply.github.com) "requested your review on"

It is almost identical to the search expression found in the original post, but it removes the OR braces around the last two search parameters. Hope that someone finds this useful!

@oscard0m
Copy link

oscard0m commented Nov 7, 2021

With latest changes in GitHub email notifications, filters for issue and pr can be improved: https://github.blog/changelog/2021-10-11-improved-notification-email-titles-for-issues-and-prs/

@erikw
Copy link

erikw commented Jul 27, 2022

ci_activity@noreply.github.com is missing from the list.

@kevinrobayna
Copy link

What kind of rules does people have for GH Actions?

@khavinshankar
Copy link

What kind of rules does people have for GH Actions?

https://gist.github.com/ldez/bd6e6401ad0855e6c0de6da19a8c50b5#github-actions

@sastorsl
Copy link

You can add push@noreply.github.com to the list.

@AntonBelski
Copy link

Very useful!

@maciejsobon
Copy link

Very handy! Cheers :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment