w3c / ash-nazg

One interface to find all group contributors and in IPR bind them
https://labs.w3.org/repo-manager/
MIT License
22 stars 18 forks source link

handle repository renames and transfers #223

Closed deniak closed 2 years ago

deniak commented 2 years ago

Fix #64

Note that:

dontcallmedom commented 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?)

deniak commented 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: [...]

Great! I'll play a bit with that code and will prepare a script.