@@ -21,7 +21,7 @@ module.exports = {
21
21
BROWSERSTACK_PROJECT_NAME: 'BROWSERSTACK_PROJECT_NAME',
22
22
},
23
23
24
- BROWSERSTACK_TEMPLATE : {
24
+ BROWSERSTACK_INTEGRATIONS : {
25
25
DETAILS_API_URL: 'https://integrate.browserstack.com/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
26
26
},
27
27
};
@@ -9329,10 +9329,9 @@ function wrappy (fn, cb) {
9329
9329
9330
9330
const core = __nccwpck_require__(2186);
9331
9331
const axios = __nccwpck_require__(8757);
9332
- const github = __nccwpck_require__(5438);
9333
9332
const InputValidator = __nccwpck_require__(4881);
9334
9333
const constants = __nccwpck_require__(1468);
9335
- const { BROWSERSTACK_TEMPLATE } = __nccwpck_require__(1468);
9334
+ const { BROWSERSTACK_INTEGRATIONS } = __nccwpck_require__(1468);
9336
9335
9337
9336
const {
9338
9337
INPUT,
@@ -9366,7 +9365,7 @@ class ActionInput {
9366
9365
this.githubApp = core.getInput(INPUT.GITHUB_APP);
9367
9366
this.rerunAttempt = process?.env?.GITHUB_RUN_ATTEMPT;
9368
9367
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 ;
9370
9369
} catch (e) {
9371
9370
throw Error(`Action input failed for reason: ${e.message}`);
9372
9371
}
@@ -9411,7 +9410,6 @@ class ActionInput {
9411
9410
9412
9411
async checkIfBStackReRun() {
9413
9412
// 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}`);
9415
9413
if (!this.rerunAttempt || !this.rerunAttempt > 1) {
9416
9414
return false;
9417
9415
}
@@ -9445,7 +9443,7 @@ class ActionInput {
9445
9443
// Check if the run was triggered by the BrowserStack rerun bot
9446
9444
core.info('The re-run was triggered by the GitHub App from BrowserStack.');
9447
9445
9448
- const browserStackApiUrl = BROWSERSTACK_TEMPLATE .DETAILS_API_URL.replace('{runId}', this.runId);
9446
+ const browserStackApiUrl = BROWSERSTACK_INTEGRATIONS .DETAILS_API_URL.replace('{runId}', this.runId);
9449
9447
9450
9448
// Call BrowserStack API to get the tests to rerun
9451
9449
const bsApiResponse = await axios.get(browserStackApiUrl, {
@@ -9603,30 +9601,42 @@ class InputValidator {
9603
9601
* @throws {Error} If the input is not a valid non-empty string
9604
9602
*/
9605
9603
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') {
9610
9605
throw new Error("Invalid input for 'github-token'. Must be a valid non-empty string.");
9611
9606
}
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.");
9613
9617
}
9614
9618
9615
9619
/**
9616
9620
* 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
9620
9624
* @throws {Error} If the input is not a valid non-empty string
9621
9625
*/
9622
9626
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') {
9627
9628
throw new Error("Invalid input for 'github-app'. Must be a valid string.");
9628
9629
}
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.");
9630
9640
}
9631
9641
}
9632
9642
@@ -14605,7 +14615,7 @@ const ActionInput = __nccwpck_require__(9426);
14605
14615
const run = async () => {
14606
14616
try {
14607
14617
const inputParser = new ActionInput();
14608
- inputParser.setEnvVariables();
14618
+ await inputParser.setEnvVariables();
14609
14619
} catch (e) {
14610
14620
core.setFailed(`Action Failed: ${e}`);
14611
14621
}
0 commit comments