-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
84 lines (72 loc) · 2.27 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* This is the main entrypoint to your Probot app
* @param {import('probot').Application} app
*/
const robokit = app => {
const ApiGateway = require('./app/http-gateway')
const Cache = require('./app/cache')
const cache = new Cache(app)
app.log('Starting the TxBot service.')
const api = new ApiGateway(app, cache)
app.on('schedule.repository', async context => {
cache.set(context.payload.repository.owner.login, context.payload.repository.name, context.github)
})
app.on('installation', context => {
api.onAppInstall(context)
console.log('installation event:' + JSON.stringify(context))
})
app.on('check_run', context => {
console.log(context.payload.check_run.name + ' - ' + context.payload.check_run.status + ' - ' + context.payload.check_run.conclusion)
if (context.payload.requested_action) {
const action = context.payload.requested_action.identifier
context.user_action = action
}
api.deployContext(context).then(deploy => {
console.log(deploy.check_run_name)
if (deploy.is_pull_request || api.isKnownBranch(deploy) || deploy.release) {
api.deploy(context, deploy)
}
})
})
app.on([
'pull_request.synchronize',
'pull_request.labeled',
'pull_request.opened',
'pull_request.reopened',
'pull_request.unlabeled',
'pull_request.closed'
], context => {
if (context.payload.action === 'opened' || context.payload.action === 'reopened') {
const deploy = api.deployContext(context)
if (deploy.is_pull_request || api.isKnownBranch(deploy)) {
api.deploy(context, deploy)
}
}
})
app.on([
'issue_comment',
'issues',
'push'], async context => {
// api.route(context);
})
console.log('Server Started.')
api.start()
//smee()
}
function smee () {
if (global.env.WEBHOOK_PROXY_URL) {
const SmeeClient = require('smee-client')
const smee = new SmeeClient({
source: global.env.WEBHOOK_PROXY_URL,
target: `http://localhost:${global.env.PORT}`,
logger: console
})
smee.start()
}
}
module.exports = robokit
// For more information on building apps:
// https://probot.github.io/docs/
// To get your app running against GitHub, see:
// https://probot.github.io/docs/development/
// Authenticate as the App