Last active
March 31, 2017 19:14
-
-
Save mucbuc/3fabfb103ef96cbf468d06e0b2e227b1 to your computer and use it in GitHub Desktop.
test-bot-invoke
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example of aws-lambda kicking off unit tests triggered by github commits. Amazon SNS | |
is used for integration with github | |
*/ | |
'use strict'; | |
const http = require( 'http' ) | |
, ip = process.env.BOT_IP; | |
exports.handler = (event, context, callback) => { | |
try { | |
const msg = JSON.parse(event.Records[0].Sns.Message) | |
, repo = msg.repository.name | |
, ref = msg.ref | |
, sha = msg.after; | |
, url = 'http://' + ip + '/' + repo + '/' + ref + '/' + sha; | |
http.get( url, (result) => { | |
callback( null, 'success:' + result.statusMessage ); | |
}) | |
.on( 'error', (error) => { | |
callback( null, 'failed:' + error ); | |
}); | |
} | |
catch( error ) { | |
callback( null, 'failed:' + error ); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment