1
0
mirror of https://github.com/spacebarchat/spacebarchat.git synced 2024-11-22 18:32:36 +01:00
spacebarchat/scripts/github/rename_issues.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-08-10 03:34:50 +02:00
const { token } = require("./config.json");
const fetch = require("node-fetch");
const base = "https://api.github.com";
const organization = "fosscord";
const request = async (path, opts = {}) =>
await fetch(`${base}${path}`, {
...opts,
headers: {
...opts.headers,
Authorization: `token ${token}`,
},
}).then((response) => response.json());
async function getRepos() {
return (await request(`/orgs/${organization}/repos`)).map((repo) => repo.name);
}
async function main() {
2021-08-13 01:06:33 +02:00
// const repos = await getRepos();
const repos = ["fosscord-gateway"];
2021-08-10 03:34:50 +02:00
for (const repo of repos) {
var page = 1;
do {
var issues = await request(`/repos/${organization}/${repo}/issues?state=all&per_page=100&page=${page}`);
for (const issue of issues) {
2021-08-13 01:06:33 +02:00
console.log(`issue #${issue.number}`);
// continue;
await request(`/repos/${organization}/${repo}/issues/${issue.number}`, {
method: "PATCH",
body: JSON.stringify({ labels: ["gateway"] }),
});
2021-08-10 03:34:50 +02:00
}
page++;
} while (issues.length);
}
}
main()
.then(() => console.log("done"))
.catch(console.error);