GitHub.js

List the webhooks for a user’s repositories

var GitHub = require("github-api");
var Promise = require("es6-promise").Promise;

var gh = new GitHub({
  username: 'foo',
  password: 'bar'
});

var user = 'slunk32';
gh.getUser(user).getRepos()
  // turn the json objects we fetched into `Repository`s
  .then(function(httpPromise) {
      return httpPromise.data.map(function(repoJson) {
          // console.log('repo '  repoJson.name);
          return gh.getRepo(user, repoJson.name);
      });
  })
  // Curry promises to fetch webhooks
   .then(function(repos) {
      console.log(repos);
      return Promise.all(repos.map(function(repo) {
          return repo.listHooks();
      }));
   })
   // Fetch the webhooks json
   .then(function(listOfListOfHooks) {
       listOfListOfHooks = listOfListOfHooks || []; // monkey-patch for non-authenticated users
       listOfListOfHooks.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

var GitHub = require("github-api");
var Promise = require("es6-promise").Promise;

var gh = new GitHub({
  username: 'foo',
  password: 'bar'
});

var fork = gh.getRepository('user', 'repo');

var hookDef = {
  "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...");
  });
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy