forked from lambci/lambci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (20 loc) · 870 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var config = require('./utils/config')
var log = require('./utils/log')
var cfn = require('./cfn')
var actions = require('./actions')
var webhook = require('./sources/webhook')
exports.handler = function(event, context, cb) {
log.init(`LambCI v${config.VERSION} triggered on stack "${config.STACK}"\n`) // STACK is usually 'lambci'
// Check if it's the CloudFormation stack calling us
if (event.ResourceType == 'Custom::ConfigUpdater') {
return cfn.update(event, context, cb)
// Or a custom (manual) event
} else if (typeof actions[event.action] == 'function') {
return actions[event.action](event, context, cb)
// Otherwise it should be a GitHub webhook
} else if (event.httpMethod == 'POST') {
return webhook.build(event, context, cb)
}
log.error('Unknown event, ignoring:\n%j', event)
return cb(new Error('Unknown event'))
}