-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscript.js
49 lines (43 loc) · 1.26 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
/**
* Create a CODE_OF_CONDUCT.md file unless it already exists.
* Ignores forks and archived repositories
*
* @param {import('@octoherd/cli').Octokit} octokit
* @param {import('@octoherd/cli').Repository} repository
*/
export async function script(octokit, repository) {
if (repository.archived) {
octokit.log.info(`${repository.html_url} is archived, ignoring.`);
return;
}
const owner = repository.owner.login;
const repo = repository.name;
const path = ".github/dependabot.yml";
const sha = await octokit
.request("GET /repos/{owner}/{repo}/contents/{path}", {
owner,
repo,
path,
})
.then(
(response) => response.data.sha,
(error) => null
);
if (!sha) {
octokit.log.info(`${path} does not exist in ${repository.html_url}`);
return;
}
const {
data: { commit },
} = await octokit.request("DELETE /repos/{owner}/{repo}/contents/{path}", {
owner,
repo,
path,
sha,
message: `build(dependabot): disable by removing configuration
I'm taking a break. I'll enable automated dependency updates when I'm back in 2021. But probably not with Dependabot, but Renovate.`,
});
octokit.log.info(
`${path} deleted in ${repository.html_url} via ${commit.html_url}`
);
}