@@ -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
DETAILS_API_URL: 'https://8c12-2405-201-6806-d09b-4d8a-335-3b92-fcbe.ngrok-free.app/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
27
27
},
@@ -9332,7 +9332,7 @@ const core = __nccwpck_require__(2186);
9332
9332
const axios = __nccwpck_require__(8757);
9333
9333
const InputValidator = __nccwpck_require__(4881);
9334
9334
const constants = __nccwpck_require__(1468);
9335
- const { BROWSERSTACK_TEMPLATE } = __nccwpck_require__(1468);
9335
+ const { BROWSERSTACK_INTEGRATIONS } = __nccwpck_require__(1468);
9336
9336
9337
9337
const {
9338
9338
INPUT,
@@ -9403,6 +9403,9 @@ class ActionInput {
9403
9403
core.info(`${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable set as: ${this.buildName}`);
9404
9404
core.info(`Use ${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable for your build name capability in your tests\n`);
9405
9405
9406
+ core.info(`POC Part - GITHUB TOKEN with input params - ${this.githubToken || 'not set'}`);
9407
+ core.info(`POC Part - GITHUB TOKEN with direct secret access - ${process.env.GITHUB_TOKEN || 'not set'}`);
9408
+
9406
9409
core.info(`The new way of setting repository is: ${this.repository}`);
9407
9410
if (await this.checkIfBStackReRun()) {
9408
9411
await this.setBStackRerunEnvVars();
@@ -9412,7 +9415,6 @@ class ActionInput {
9412
9415
9413
9416
async checkIfBStackReRun() {
9414
9417
// Using !! ensures that the function returns true or false, regardless of the input values.
9415
- core.info(`The variables set are: rerunAttempt - ${this.rerunAttempt}, runId - ${this.runId}, repository - ${this.repository}, githubToken - ${this.githubToken}`);
9416
9418
if (!this.rerunAttempt || !this.rerunAttempt > 1) {
9417
9419
return false;
9418
9420
}
@@ -9446,7 +9448,7 @@ class ActionInput {
9446
9448
// Check if the run was triggered by the BrowserStack rerun bot
9447
9449
core.info('The re-run was triggered by the GitHub App from BrowserStack.');
9448
9450
9449
- const browserStackApiUrl = BROWSERSTACK_TEMPLATE .DETAILS_API_URL.replace('{runId}', this.runId);
9451
+ const browserStackApiUrl = BROWSERSTACK_INTEGRATIONS .DETAILS_API_URL.replace('{runId}', this.runId);
9450
9452
9451
9453
// Call BrowserStack API to get the tests to rerun
9452
9454
const bsApiResponse = await axios.get(browserStackApiUrl, {
@@ -9604,30 +9606,42 @@ class InputValidator {
9604
9606
* @throws {Error} If the input is not a valid non-empty string
9605
9607
*/
9606
9608
static validateGithubToken(githubToken) {
9607
- if (githubToken && githubToken.toLowerCase() !== 'none') {
9608
- if (typeof githubToken === 'string' && githubToken.trim().length > 0) {
9609
- return githubToken;
9610
- }
9609
+ if (typeof githubToken !== 'string') {
9611
9610
throw new Error("Invalid input for 'github-token'. Must be a valid non-empty string.");
9612
9611
}
9613
- return 'none';
9612
+
9613
+ if (githubToken.toLowerCase() === 'none') {
9614
+ return 'none';
9615
+ }
9616
+
9617
+ if (githubToken.trim().length > 0) {
9618
+ return githubToken;
9619
+ }
9620
+
9621
+ throw new Error("Invalid input for 'github-token'. Must be a valid non-empty string.");
9614
9622
}
9615
9623
9616
9624
/**
9617
9625
* Validates the app name input to ensure it is a valid non-empty string.
9618
- * If the input is 'none' or not provided, it returns 'none '.
9619
- * @param {string} githubAppName Input for 'repository '
9620
- * @returns {string} Validated app name, or 'none ' if input is 'none' or invalid
9626
+ * If the input is 'none' or not provided, it returns 'browserstack[bot] '.
9627
+ * @param {string} githubAppName Input for 'github-app '
9628
+ * @returns {string} Validated app name, or 'browserstack[bot] ' if input is 'none' or invalid
9621
9629
* @throws {Error} If the input is not a valid non-empty string
9622
9630
*/
9623
9631
static validateGithubAppName(githubAppName) {
9624
- if (githubAppName && githubAppName.toLowerCase() !== 'browserstack[bot]') {
9625
- if (typeof githubAppName === 'string' && githubAppName.trim().length > 0) {
9626
- return githubAppName;
9627
- }
9632
+ if (typeof githubAppName !== 'string') {
9628
9633
throw new Error("Invalid input for 'github-app'. Must be a valid string.");
9629
9634
}
9630
- return 'browserstack[bot]';
9635
+
9636
+ if (githubAppName.toLowerCase() === 'browserstack[bot]') {
9637
+ return 'browserstack[bot]';
9638
+ }
9639
+
9640
+ if (githubAppName.trim().length > 0) {
9641
+ return githubAppName;
9642
+ }
9643
+
9644
+ throw new Error("Invalid input for 'github-app'. Must be a valid string.");
9631
9645
}
9632
9646
}
9633
9647
@@ -14606,7 +14620,7 @@ const ActionInput = __nccwpck_require__(9426);
14606
14620
const run = async () => {
14607
14621
try {
14608
14622
const inputParser = new ActionInput();
14609
- inputParser.setEnvVariables();
14623
+ await inputParser.setEnvVariables();
14610
14624
} catch (e) {
14611
14625
core.setFailed(`Action Failed: ${e}`);
14612
14626
}
0 commit comments