Does anyone know of a way to have GitHub email commit/pull request notifications including the full diff of the commit?
I know about the email service hook, but that doesn't send the diff.
Does anyone know of a way to have GitHub email commit/pull request notifications including the full diff of the commit?
I know about the email service hook, but that doesn't send the diff.
At this time, there is no way to do what you want using just GitHub. As noted in https://stackoverflow.com/questions/4211107/how-to-get-email-diffs-for-github-pushes, there is no support within GitHub to send e-mails including diffs. There are two GitHub issues raised asking about this - http://github.com/github/github-services/issues/86 (closed) and http://github.com/github/github-services/issues/149 but although they say this is something they might implement in the future, there is no indication this will happen.
That said, if you are willing to run your own (local or cloud hosted, but with scripting) web or e-mail server with git repository, you could build this yourself using GitHub post-receive notifications (http://help.github.com/articles/post-receive-hooks) sent to your web server, or normal (without diffs) e-mail notifications sent to a special address on your e-mail server. The choice between web and e-mail notification would be made depending on where & how you are hosting your server - if you have good connectivity & reliability, web notifications will have lowest latency, but if your web-server is unreachable for any reason, you won't get a notification until the next commit that is made while your web-server is reachable; using e-mail will delay the whole process, but might be preferable if you are hosting this at home, and especially for any machine that is not always on.
In either case, you would have to write a script that takes the (e-mail or web/JSON) notification and pulls the relevant repo(s) from GitHub to a local repository, where you would have to set up Git's internal post-receive hook mechanism to run something like http://github.com/jtek/git-hook-update-notify-email (mentioned in the above stackoverflow article) or if you're willing & able to install & use Pygments (Python code colorizer) perhaps something nicer looking like http://blog.chomperstomp.com/making-git-show-post-receive-e-mails-as-an-html-color-formatted-diff/ (linked to/from https://stackoverflow.com/questions/3232270/git-post-receive-email-hook-to-show-an-html-formatted-color-diff/).
It's a bit of scripting work, and requires that you have some hosting infrastructure to run the web or e-mail server, the local-pull script, and then the local post-receive hook to generate the actual e-mail with diffs, but it should be possible to set this up in less than a day.
It's possible generate git diff on each push and send it via email using Github Actions. Here is the example
...
- name: Generate git diff since last push
run: |
# write raw git diff in file
git diff ${{ github.event.before }} ${{ github.sha }} > git.diff
# convert raw git diff to html
git diff ${{ github.event.before }} ${{ github.sha }} | bash ./.github/diff2html.sh > email-body.html
zip -r diff.zip git.diff email-body.html
- name: Send git diff mail
uses: dawidd6/action-send-mail@v2
with:
server_address: email-smtp.us-east-1.amazonaws.com
server_port: 465
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: Github Actions job result
# Read file contents as body:
body: file://email-body.html
to: [email protected]
from: Luke Skywalker <[email protected]>
# Optional content type (defaults to text/plain):
content_type: text/html
attachments: diff.zip
...
Converted git diff to HTML page is stored here https://github.com/sturman/git-diff-email/blob/master/email-body-example.html
The full project is stored here https://github.com/sturman/git-diff-email/