-
-
Save tjfontaine/623f36cebd6e3bdeec52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gh = require('github') | |
function update(token, repos) { | |
var github = new gh({ | |
version: "3.0.0", | |
//debug: true, | |
}); | |
github.authenticate({ | |
type: 'oauth', | |
token: token, | |
}); | |
repos.forEach(function (repo) { | |
var s = repo.split('/'); | |
var user = s[0]; | |
var name = s[1]; | |
github.repos.getHooks({ | |
user: user, | |
repo: name, | |
}, function (err, result) { | |
var i, hook, found = []; | |
for (i in result) { | |
hook = result[i]; | |
if (hook.name === 'web' && hook.config.url.match(/^http:\/\/jenkins.nodejs.org\/github/)) { | |
console.log(i, hook); | |
found.push(hook.id); | |
} | |
} | |
hook = found.pop(); | |
if (hook) { | |
console.log('update hook', hook); | |
github.repos.updateHook({ | |
user: user, | |
repo: name, | |
name: 'web', | |
id: hook, | |
config: { | |
url: 'http://jenkins.nodejs.org/github-webhook/', | |
content_type: 'json', | |
}, | |
events: [ | |
'push', | |
'issues', | |
'issue_comment', | |
'pull_request', | |
'pull_request_review_comment', | |
'commit_comment', | |
], | |
active: true, | |
}, function (err, res) { | |
console.log(res); | |
}); | |
} | |
if (hook) | |
return; | |
}); | |
}); | |
} | |
var repos = [ | |
'joyent/node', | |
'joyent/libuv', | |
]; | |
//var GITHUBTOKEN = ''; | |
//update(GITHUBTOKEN, repos); | |
var octOAuth = require('octoauth'); | |
var oauth = new octOAuth({ | |
username: SOMEUSERNAME, | |
password: SOMEPASSWORD, | |
}) | |
oauth.scopes = ['public_repo']; | |
oauth.getToken(function (err, token) { | |
console.log('save this for script reuse -- octoauth token', token); | |
update(token, repos); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment