@@ -21,7 +21,7 @@ module.exports = {
2121 BROWSERSTACK_PROJECT_NAME: 'BROWSERSTACK_PROJECT_NAME',
2222 },
2323
24- BROWSERSTACK_TEMPLATE : {
24+ BROWSERSTACK_INTEGRATIONS : {
2525 DETAILS_API_URL: 'https://integrate.browserstack.com/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
2626 },
2727};
@@ -9329,10 +9329,9 @@ function wrappy (fn, cb) {
93299329
93309330const core = __nccwpck_require__(2186);
93319331const axios = __nccwpck_require__(8757);
9332- const github = __nccwpck_require__(5438);
93339332const InputValidator = __nccwpck_require__(4881);
93349333const constants = __nccwpck_require__(1468);
9335- const { BROWSERSTACK_TEMPLATE } = __nccwpck_require__(1468);
9334+ const { BROWSERSTACK_INTEGRATIONS } = __nccwpck_require__(1468);
93369335
93379336const {
93389337 INPUT,
@@ -9366,7 +9365,7 @@ class ActionInput {
93669365 this.githubApp = core.getInput(INPUT.GITHUB_APP);
93679366 this.rerunAttempt = process?.env?.GITHUB_RUN_ATTEMPT;
93689367 this.runId = process?.env?.GITHUB_RUN_ID;
9369- this.repository = `${github?.context?.repo?.owner}/${github?.context?.repo?.repo}` ;
9368+ this.repository = process?.env?.GITHUB_REPOSITORY ;
93709369 } catch (e) {
93719370 throw Error(`Action input failed for reason: ${e.message}`);
93729371 }
@@ -9411,7 +9410,6 @@ class ActionInput {
94119410
94129411 async checkIfBStackReRun() {
94139412 // Using !! ensures that the function returns true or false, regardless of the input values.
9414- core.info(`The variables set are: rerunAttempt - ${this.rerunAttempt}, runId - ${this.runId}, repository - ${this.repository}, githubToken - ${this.githubToken}`);
94159413 if (!this.rerunAttempt || !this.rerunAttempt > 1) {
94169414 return false;
94179415 }
@@ -9445,7 +9443,7 @@ class ActionInput {
94459443 // Check if the run was triggered by the BrowserStack rerun bot
94469444 core.info('The re-run was triggered by the GitHub App from BrowserStack.');
94479445
9448- const browserStackApiUrl = BROWSERSTACK_TEMPLATE .DETAILS_API_URL.replace('{runId}', this.runId);
9446+ const browserStackApiUrl = BROWSERSTACK_INTEGRATIONS .DETAILS_API_URL.replace('{runId}', this.runId);
94499447
94509448 // Call BrowserStack API to get the tests to rerun
94519449 const bsApiResponse = await axios.get(browserStackApiUrl, {
@@ -9603,30 +9601,42 @@ class InputValidator {
96039601 * @throws {Error} If the input is not a valid non-empty string
96049602 */
96059603 static validateGithubToken(githubToken) {
9606- if (githubToken && githubToken.toLowerCase() !== 'none') {
9607- if (typeof githubToken === 'string' && githubToken.trim().length > 0) {
9608- return githubToken;
9609- }
9604+ if (typeof githubToken !== 'string') {
96109605 throw new Error("Invalid input for 'github-token'. Must be a valid non-empty string.");
96119606 }
9612- return 'none';
9607+
9608+ if (githubToken.toLowerCase() === 'none') {
9609+ return 'none';
9610+ }
9611+
9612+ if (githubToken.trim().length > 0) {
9613+ return githubToken;
9614+ }
9615+
9616+ throw new Error("Invalid input for 'github-token'. Must be a valid non-empty string.");
96139617 }
96149618
96159619 /**
96169620 * Validates the app name input to ensure it is a valid non-empty string.
9617- * If the input is 'none' or not provided, it returns 'none '.
9618- * @param {string} githubAppName Input for 'repository '
9619- * @returns {string} Validated app name, or 'none ' if input is 'none' or invalid
9621+ * If the input is 'none' or not provided, it returns 'browserstack[bot] '.
9622+ * @param {string} githubAppName Input for 'github-app '
9623+ * @returns {string} Validated app name, or 'browserstack[bot] ' if input is 'none' or invalid
96209624 * @throws {Error} If the input is not a valid non-empty string
96219625 */
96229626 static validateGithubAppName(githubAppName) {
9623- if (githubAppName && githubAppName.toLowerCase() !== 'browserstack[bot]') {
9624- if (typeof githubAppName === 'string' && githubAppName.trim().length > 0) {
9625- return githubAppName;
9626- }
9627+ if (typeof githubAppName !== 'string') {
96279628 throw new Error("Invalid input for 'github-app'. Must be a valid string.");
96289629 }
9629- return 'browserstack[bot]';
9630+
9631+ if (githubAppName.toLowerCase() === 'browserstack[bot]') {
9632+ return 'browserstack[bot]';
9633+ }
9634+
9635+ if (githubAppName.trim().length > 0) {
9636+ return githubAppName;
9637+ }
9638+
9639+ throw new Error("Invalid input for 'github-app'. Must be a valid string.");
96309640 }
96319641}
96329642
@@ -14605,7 +14615,7 @@ const ActionInput = __nccwpck_require__(9426);
1460514615const run = async () => {
1460614616 try {
1460714617 const inputParser = new ActionInput();
14608- inputParser.setEnvVariables();
14618+ await inputParser.setEnvVariables();
1460914619 } catch (e) {
1461014620 core.setFailed(`Action Failed: ${e}`);
1461114621 }
0 commit comments