forked from mirrors/probot
Add routing plugin
This commit is contained in:
parent
3d123908ba
commit
ee6e77c2f9
|
@ -0,0 +1,17 @@
|
|||
const Plugin = require('../plugin');
|
||||
const Configuration = require('../configuration');
|
||||
const url = require('../util/github-url');
|
||||
|
||||
console.log("WTF?", Configuration, Configuration.load);
|
||||
|
||||
module.exports = class Routing extends Plugin {
|
||||
route(context, path) {
|
||||
console.log(Configuration, Configuration.load)
|
||||
return Configuration.load(context, path).then(config => {
|
||||
const parts = url(path);
|
||||
context.event.payload.repository.name = parts.repo;
|
||||
context.event.payload.repository.owner.login = parts.owner;
|
||||
return config.execute(context);
|
||||
});
|
||||
}
|
||||
}
|
19
lib/robot.js
19
lib/robot.js
|
@ -11,14 +11,19 @@ class Robot {
|
|||
receive(event) {
|
||||
log.trace('webhook', event);
|
||||
|
||||
if (event.payload.repository) {
|
||||
installations.auth(event.payload.installation.id).then(github => {
|
||||
const context = new Context(github, event);
|
||||
Configuration.load(context, '.probot.js').then(config => {
|
||||
return config.execute();
|
||||
});
|
||||
});
|
||||
if(!event.payload.repository) {
|
||||
event.payload.repository = {
|
||||
name: 'probot-scripts',
|
||||
owner: event.payload.organization
|
||||
}
|
||||
}
|
||||
|
||||
installations.auth(event.payload.installation.id).then(github => {
|
||||
const context = new Context(github, event);
|
||||
Configuration.load(context, '.probot.js').then(config => {
|
||||
return config.execute();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
const Issues = require('./plugins/issues');
|
||||
const Routing = require('./plugins/routing');
|
||||
|
||||
const plugins = [
|
||||
new Issues()
|
||||
new Issues(),
|
||||
new Routing()
|
||||
];
|
||||
|
||||
module.exports = class Workflow {
|
||||
|
|
Loading…
Reference in New Issue