diff --git a/src/getToken.ts b/src/getToken.ts index 4d67cfc..b581e6e 100644 --- a/src/getToken.ts +++ b/src/getToken.ts @@ -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; + 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) { @@ -36,4 +36,4 @@ const getEnvirontment: any = process.env; return getGHToken; } -export default getToken; +export default getToken; \ No newline at end of file