Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to notify other users when git commit or push

Tags:

git

github

I am not using any review tools (e.g. pull request), and just want to email notify the whole team if anyone is executing git commit or git push (notification is just for their information purpose, no need for their review). Wondering if any solutions either from either git command line or github.com setup.

like image 657
Lin Ma Avatar asked Jul 17 '16 22:07

Lin Ma


People also ask

Does GitHub notify users?

There are no ways to do it because GitHub delivers only two kinds of notifications: Participating: Someone mentions you or a team you're a member of. You are assigned to an issue or pull request.

How do I send notifications on GitHub?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. In the "Integrations" section of the sidebar, click Email notifications. Type up to two email addresses, separated by whitespace, where you'd like notifications to be sent.

How do I get notifications from GitHub?

In the left sidebar, under the list of repositories, use the "Manage notifications" drop-down to click Notification settings. On the notifications settings page, choose how you receive notifications when: There are updates in repositories or team discussions you're watching or in a conversation you're participating in.


2 Answers

GitHub includes a built-in webhook to send emails for pushes in a repository. You can set that up from the “Webhooks & services” configuration of a repository. See this official manual for more details.

In addition, you could set up your own webhooks to send out notifications. As for notifications on committing, you could do that too using normal Git hooks, but since commits happen locally (and offline), every member of your team would be required to set up that Git hook and also agree to send out emails automatically whenever they commit. I personally wouldn’t want that at all. It’s a strong feature that you are able to push only when you are ready with your commits, so you shouldn’t take that away from users (and I personally commit a lot more often than my final history shows—those commits are not meant for others but only for me).

like image 114
poke Avatar answered Oct 20 '22 00:10

poke


I'll assume you wish to monitor pushes to remote (I have a solution for local as well at the end) and for that you can use GitHub webhooks as mentioned in @poke's response.

Just to give an alternate answer for anyone else looking to try it out. If you rather not build your own consumption pipeline, consider using LightFlare (I'm the creator) that has out of the box support of consuming Webhooks events from many services (github included) and notifies you at your choice(s) of destinations (slack / email etc ...).

LightFlare currently supports monitoring on services like:

  • Infra: GCP, AWS, Azure, heroku
  • Code/release: GitHub, bitbucket, netlify
  • Commerce: shopify, gumroad
  • More integrations based on our customers asks

With LightFlare, you can track local commits as well .. just have to add a git hook that curl's to your lightflare channel URL.

like image 33
Ras Avatar answered Oct 19 '22 23:10

Ras