-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
52 lines (46 loc) · 1.19 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* close renovate dashboard issues
*
* @param {import('@octoherd/cli').Octokit} octokit
* @param {import('@octoherd/cli').Repository} repository
*/
export async function script(octokit, repository) {
const owner = repository.owner.login;
const repo = repository.name;
if (repository.archived) {
octokit.log.info(
{ updated: false, reason: "archived" },
`${repository.html_url} is archived`
);
return;
}
const iterator = await octokit.paginate.iterator(
"GET /repos/{owner}/{repo}/issues",
{
owner,
repo,
state: "open",
creator: "renovate[bot]",
}
);
for await (const { data: issues } of iterator) {
for (const issue of issues) {
if (issue.title !== "Dependency Dashboard") continue;
await octokit.request(
"PATCH /repos/{owner}/{repo}/issues/{issue_number}",
{
owner,
repo,
issue_number: issue.number,
state: "closed",
}
);
octokit.log.info({ updated: true }, `${issue.html_url} closed`);
return;
}
}
octokit.log.info(
{ updated: false, reason: "not found" },
`No dashboard issue found in ${repository.html_url}`
);
}