github-readme-stats/scripts/helpers.js
Rick Staa b8faef6857
ci: add stale theme pull request closer action push (#2067)
This commit adds the `stale-theme-pr-closer` closer action. This action
is used to close theme pull requests with an `invalid` label that has
been stale for a given number of `STALE_DAYS`.
2022-10-02 11:05:13 +02:00

40 lines
832 B
JavaScript

/**
* @file Contains helper functions used in the scripts.
*/
// Script variables.
const OWNER = "anuraghazra";
const REPO = "github-readme-stats";
/**
* Retrieve information about the repository that ran the action.
*
* @param {Object} context Action context.
* @returns {Object} Repository information.
*/
export const getRepoInfo = (ctx) => {
try {
return {
owner: ctx.repo.owner,
repo: ctx.repo.repo,
};
} catch (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 = core.getInput("github_token") || process.env.GITHUB_TOKEN;
if (!token) {
throw Error("Could not find github token");
}
return token;
};