简体   繁体   English

Github 文件更改通知

[英]Github file change notification

Is there a way to notify people on change of some certain files?有没有办法通知人们某些文件的更改? Specifically, I would like to track change of *.sql files and and notify our developers on a change.具体来说,我想跟踪 *.sql 文件的更改并通知我们的开发人员发生更改。 How can I configure post commit hooks to notify?如何配置提交后挂钩以进行通知?

如果您希望人们通过电子邮件收到通知,并且希望他们管理自己的通知,那么https://app.github-file-watcher.com/应该可以解决问题 - 它会监控任何公共存储库,并会通知您通过电子邮件更改任何文件、特定文件或某些符合您条件的文件。

Use git diff-tree in your post-receive hook :在你的post-receive hook 中使用git diff-tree

 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 .您可以 grep 结果以检查某些文件是否被修改(状态“ M ”),如本答案所述
you can find many examples on gist.github.com , with this one using the --name-status option.您可以gist.github.com上找到许多示例,其中一个使用--name-status选项。

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.我查看了 Cooper 的 GitHub File Watcher,但它不适用于私有存储库,也不是开源的。

So I just ended up building my own solution: https://github.com/jesalg/commit-hawk .所以我最终构建了自己的解决方案: https : //github.com/jesalg/commit-hawk Posting this here just in case someone is still looking for a tool like that.在这里发布这个以防万一有人仍在寻找这样的工具。

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. GitHub(截至 2019 年 12 月)在预览版中有一些新的通知功能,包括CODEOWNERS的概念,它允许对如何为更改配置通知进行相当精细的控制。

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/ .需要启用预览功能才能使其工作,但接下来需要做的就是在根目录、 docs/.github/创建一个CODEOWNERS文件。

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 docs@example.com

# 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/*  docs@example.com

# 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 this is really an old question, but here is a solution you can deploy via a github webhook on a repo.我知道这确实是一个老问题,但这里有一个解决方案,您可以通过 github webhook 在 repo 上进行部署。 You can also customize and change the code to look for specific file patterns and notify you via email, slack, text or other means.您还可以自定义和更改代码以查找特定文件模式并通过电子邮件、slack、文本或其他方式通知您。 Hope this is helpful.希望这是有帮助的。

Here is the code for it: https://github.com/DevScoreInc/samples/tree/master/github-file-monitor这是它的代码: https : //github.com/DevScoreInc/samples/tree/master/github-file-monitor

Here is a demo that shows exactly how to configure this: https://youtu.be/6HgxIkT8EQ4这是一个演示,确切显示了如何配置: https : //youtu.be/6HgxIkT8EQ4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM