forked from deepset-ai/haystack-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.ts
44 lines (40 loc) · 1.03 KB
/
github.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
import { Octokit } from "octokit";
export const octokit = new Octokit({
auth: process.env.GITHUB_PERSONAL_ACCESS_TOKEN,
});
export const getDownloadUrl = async ({
filename,
repoPath,
version,
}: {
filename: string;
repoPath: string;
version?: string;
}) => {
try {
const res = await octokit.rest.repos.getContent({
owner: "deepset-ai",
repo: "haystack",
path: `docs${version && version !== "latest" ? `/${version}` : ""}${repoPath}${filename}`,
});
if (Array.isArray(res.data)) return;
if (!res.data.download_url) return;
return res.data.download_url;
} catch (e) {
return;
}
};
export const getStargazersCount = async () => {
const res = await octokit.rest.repos.get({
owner: "deepset-ai",
repo: "haystack",
});
return res.data.stargazers_count;
};
export const getHaystackReleaseTagNames = async () => {
const res = await octokit.rest.repos.listReleases({
owner: "deepset-ai",
repo: "haystack",
});
return res.data.map((release) => release.tag_name);
};