Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/getToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ dotenv.config();
* @returns {string} - The GitHub token.
*/
function getToken(bearerHeader: boolean): string {
const getEnvirontment: any = process.env;
let getGHEnvirontment: any = Object.keys(getEnvirontment).filter((key) =>
const getEnvironment = process.env as Record<string, string | undefined>;
const getGHEnvironmentKeys = Object.keys(getEnvironment).filter((key) =>
key.startsWith("GH_TOKEN")
);
getGHEnvirontment = getGHEnvirontment.map((key: string) => getEnvirontment[key]);
const getGHEnvironmentValues = getGHEnvironmentKeys.map((key: string) => getEnvironment[key]);

// Select a random GitHub environment variable
let getGHToken: string =
getGHEnvirontment[Math.floor(Math.random() * getGHEnvirontment.length)];
getGHEnvironmentValues[Math.floor(Math.random() * getGHEnvironmentValues.length)] || "";

// If no GitHub environment variable is found, get the token from GitHub Actions inputs
if (!getGHToken) {
Expand All @@ -36,4 +36,4 @@ const getEnvirontment: any = process.env;
return getGHToken;
}

export default getToken;
export default getToken;
Loading