forked from anuraghazra/github-readme-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.js
44 lines (39 loc) · 894 Bytes
/
helpers.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
/**
* @file Contains helper functions used in the scripts.
*/
import { getInput } from "@actions/core";
const OWNER = "anuraghazra";
const REPO = "github-readme-stats";
/**
* Retrieve information about the repository that ran the action.
*
* @param {Object} ctx Action context.
* @returns {Object} Repository information.
*/
export const getRepoInfo = (ctx) => {
try {
return {
owner: ctx.repo.owner,
repo: ctx.repo.repo,
};
} catch (error) {
// Resolve eslint no-unused-vars
error;
return {
owner: OWNER,
repo: REPO,
};
}
};
/**
* Retrieve github token and throw error if it is not found.
*
* @returns {string} GitHub token.
*/
export const getGithubToken = () => {
const token = getInput("github_token") || process.env.GITHUB_TOKEN;
if (!token) {
throw Error("Could not find github token");
}
return token;
};