Closed deniak closed 2 years ago
Here is some code I had used a while ago to update our existing web hooks, that could be updated and adapted to this case as well:
var GH = require("./gh");
var config = require("./config.json");
var hookURL = config.hookURL;
function setHook(gh, repo) {
return function (hooks) {
if (true || !hooks || !hooks.length || !hooks.some(function (h) { return h.config.url === hookURL; })) {
store.getSecret(repo.owner + "/" + repo.name, function(err, secret) {
gh.octo.repos(repo.owner, repo.name).hooks.create({
name: "web"
, config: {
url: config.hookURL || (config.url + "api/hook")
, content_type: "json"
, secret: secret.secret
}
, events: ["pull_request", "issue_comment"]
, active: true
})
.then(function () { console.log("Hook installed for " + repo.owner + "/" + repo.name); }).catch(function(err) { console.error("Error installing hook for repo " + repo.owner + "/" + repo.name, err)});
;
});
} else {
return console.log("Hook for " + repo.owner + "/" + repo.name + " already installed");
}
}
}
(a cleaned up version might benefit from living in this repo as a helper tool?)
Here is some code I had used a while ago to update our existing web hooks, that could be updated and adapted to this case as well: [...]
Great! I'll play a bit with that code and will prepare a script.
Fix #64
Note that:
store.js
) to fetch all the PRs of a given repositoryrepository
events