A webhook for GitHub's push events to provide a unified diff in an email. Created as a Lambda function to be used with API Gateway.
For some additional information on some settings in AWS head over here: http://www.tonytruong.net/getting-github-unified-diff-emails-using-aws-lambda-and-api-gateway/
Serverless version here which will do all the heavy lifting for deployment: https://github.com/serinth/serverless-github-diff-emailer
AWS Lambda currently supports up to version 4.3.2 but I've built this and packaged it on 5.7+ so that should be fine.
- API Gateway full access
- IAM Execution Role creation access
- Lambda full access
- SMTP server credentials
Make sure you modify the config.json: If you're on a secure connection already to the mail server then:
- Make username and password blank
- Check to see if you're using port 25 (the default for non secure channel)
{
"mailConfig":{
"host": "SMTP SERVER",
"username": "USERNAME",
"password": "PASSWORD",
"to": "[email protected],[email protected]",
"port": 465,
"secure": true,
"requireTLS": true,
"authMethod": "LOGIN"
},
"github":{
"secret": "github web hook secret"
}
}
The high level overview of what you need is:
- Clone this repository and use
npm install --save
and zip up the contents includingnode_modules
- Create the API Gateway endpoint and point to a lambda function
- Create the lambda function using the zip file you created with this code
- Create an IAM Execution role for the lambda function and give the API Gateway permissions to invoke this function
- Point the API Gateway endpoint to use this lambda function
- Apply pass-through mappings on the API Gateway so the lambda function can access the headers and body. Use the provided body-mapping for 'application/json' from AWS in the dropdown. It should look similar to this: