You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varGitHub=require("github-api");varPromise=require("es6-promise").Promise;vargh=newGitHub({username: 'foo',password: 'bar'});varuser='slunk32';gh.getUser(user).getRepos()// turn the json objects we fetched into `Repository`s.then(function(httpPromise){returnhttpPromise.data.map(function(repoJson){// console.log('repo ' repoJson.name);returngh.getRepo(user,repoJson.name);});})// Curry promises to fetch webhooks.then(function(repos){console.log(repos);returnPromise.all(repos.map(function(repo){returnrepo.listHooks();}));})// Fetch the webhooks json.then(function(listOfListOfHooks){listOfListOfHooks=listOfListOfHooks||[];// monkey-patch for non-authenticated userslistOfListOfHooks.forEach(function(hooksHttpResonse){console.log('hooks for 'hooksHttpResonse.config.url);console.log(hooksHttpResonse.data);});}).catch(function(error){console.log('an error occurred fetching the webhooks',error);});
Create a new webhook
varGitHub=require("github-api");varPromise=require("es6-promise").Promise;vargh=newGitHub({username: 'foo',password: 'bar'});varfork=gh.getRepository('user','repo');varhookDef={"name" : "travis","config" : {"user" : "your-Username","token" : "00000000000000000000000000","domain" : "http://notify.travis-ci.org","content_type": "json"},"events" : ["push","pull_request"],"active" : true}fork.createHook(hookDef).then(function({data: hook}){console.log("A travis hook has been created which will trigger a build on push and pull request events...");});