-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1-clone-repos.ts
49 lines (43 loc) · 1.25 KB
/
1-clone-repos.ts
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
import "jsr:@std/dotenv/load";
import { exists, ensureDir } from "jsr:@std/fs";
import { resolve } from "jsr:@std/path/resolve";
import { simpleGit } from "npm:simple-git";
const ORGS = ["revoltchat", "authifier"];
const IGNORE_REPO = [
"mutiny",
"themes",
"translations",
"backend-ghsa-v23v-m5mf-74jg",
];
if (import.meta.main) {
for (const org of ORGS) {
const list = await fetch(
`https://api.github.com/orgs/${org}/repos?type=sources&per_page=100`,
{
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${Deno.env.get("GH_TOKEN")}`,
"X-GitHub-Api-Version": "2022-11-28",
},
}
)
.then((res) => res.json() as Promise<{ name: string }[]>)
.then((list) =>
list.map(({ name }) => ({
name,
cwd: resolve("repos", org),
path: resolve("repos", org, name),
}))
);
for (const { name, cwd, path } of list) {
if (IGNORE_REPO.includes(name)) continue;
console.info("Cloning repository", name);
if (await exists(path)) {
await simpleGit(path).pull();
} else {
await ensureDir(cwd);
await simpleGit(cwd).clone(`https://github.com/${org}/${name}.git`);
}
}
}
}