Github file change notification
Use git diff-tree
in your post-receive hook:
git diff-tree --name-status -rz
You can grep the result to check if certain files are modified (status 'M
'), as described in this answer.
you can find many examples on gist.github.com
, with this one using the --name-status
option.
If you want folks to get notified via email, and you want them to manage their own notifications, then https://app.github-file-watcher.com/ should do the trick - it monitors any public repo, and will notify you via email of changes to any file, a specific file, or some files that match your criteria.
GitHub (as of 12/2019) has some new notification features in preview, including the concept of CODEOWNERS, which allows fairly granular control of how notifications can be configured for changes.
The Preview feature needs to be enabled for it to work, but then all that needs to be done is to create a CODEOWNERS
file in either root, docs/
, or .github/
.
Here is an example file from the documentation:
# This is a comment.
# Each line is a file pattern followed by one or more owners.
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @global-owner1 @global-owner2
# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
# modifies JS files, only @js-owner and not the global
# owner(s) will be requested for a review.
*.js @js-owner
# You can also use email addresses if you prefer. They'll be
# used to look up users just like we do for commit author
# emails.
*.go [email protected]
# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
# subdirectories.
/build/logs/ @doctocat
# The `docs/*` pattern will match files like
# `docs/getting-started.md` but not further nested files like
# `docs/build-app/troubleshooting.md`.
docs/* [email protected]
# In this example, @octocat owns any file in an apps directory
# anywhere in your repository.
apps/ @octocat
# In this example, @doctocat owns any file in the `/docs`
# directory in the root of your repository.
/docs/ @doctocat
I know it's been a while but I stumbled upon this thread when I was looking for something similar. I looked into Cooper's GitHub File Watcher but it didn't work with private repos nor was it open source.
So I just ended up building my own solution: https://github.com/jesalg/commit-hawk. Posting this here just in case someone is still looking for a tool like that.