Reputation: 2715
My team uses GitHub to host a remote git repository. I want to notify every team member of changes that were done to a specific file. How can I achieve this?
I looked at GitHub event hooks, but they seem to be capable only of sending HTTP messages to a given host when certain events happen, e.g. https://developer.github.com/v3/activity/events/types/#pushevent. So this approach requires to set up a message processing service which is way too complicated.
I also looked at git hooks and they seem promising, but have certain limitations:
Notification type could be anything, but probably email is the easiest.
Use case example: notify every team member by email that common file with error codes has been updated in the master branch of a common project. If it is not possible to fetch the list of recipients from the GitHub repo, it could be hardcoded.
Upvotes: 0
Views: 699
Reputation: 76449
If you're using github.com for your hosting, then there isn't a way to install hooks; you have to use webhooks. If you're using GitHub Enterprise Server (the on-premises version), you can use pre-receive
hooks, but they aren't ideal for this purpose; you'd really want a post-receive
hook, because there are reasons the push might be rejected and you wouldn't want to notify people needlessly.
However, there is a service, smee.io, which allows you to point your webhooks at a particular endpoint and run a client on a server you control to receive those hooks. You can point the GitHub webhooks there and then have a client which sends emails to whomever you want when you receive a response. The default smee client proxies to a local port, but you can probably modify it to run a given command instead.
Upvotes: 1