Merge bot for GitHub¶
The script gives the right to a certain circle of people to merge branches in the repository by sending the certain comment in the pull request.
Prepare IFTTT’s hooks¶
Log in / Sign up at https://ifttt.com/
Click on
Documentationbutton here: https://ifttt.com/maker_webhooksReplace
{event}with event name, for exampletravis-not-finished-pr,travis-success-prandtravis-failed-pr. Save the links you got.
Create AWS Lambda function¶
Create lambda function with following settings:
Runtime
Use
Python 3.6Environment variables
GITHUB_TOKEN– generate one in https://github.com/settings/tokens . Select scoperepo.USERNAMES– use comma-separated list of Github’s usernames without @.LOG_LEVEL– optional. Set to DEBUG to get detailed logs in AWS CloudWatch.MSG_RQST_MERGE– message-request for merge. Default:I approve to merge it nowIFTTT_HOOK_RED_PR,IFTTT_HOOK_GREEN_PR,IFTTT_HOOK_NOT_FINISHED_PR– use IFTTT’s hooks
Trigger
Use
API Gateway. Once you configure it and save, you will seeAPI endpointunder Api Gateway details section. Use optionOpenNow register the URL as webhook at github: https://developer.github.com/webhooks/creating/. Use following webhook settings:
Payload URL – the URL
Content Type: application/json
Which events would you like to trigger this webhook? – Let me select individual events and then select
[x] Issue comments
Function Code
Basic settings
Change time running function by 15 sec –
Timeout(default 3 sec)
Create IFTTT applets¶
If – Service Webhooks.
Use
{event}fromPrepare IFTTT's hooksof this instruction. For example:Event Name=travis-not-finished-pr,Event Name=travis-failed-pr.Then – whatever you like. For actions with text ingredients use following for failed, success and not finished checks:
Value1– Author of the mergeValue2– Author of the pull-requestValue3– Link to pull-request
Logs¶
AWS CloudWatch: https://console.aws.amazon.com/cloudwatch . Choice tab
LogsIFTTT logs: https://ifttt.com/activity