From 7f73d9c17e4dbf9dd77433026d8bafde62e3f0b0 Mon Sep 17 00:00:00 2001 From: Darpan Lalwani Date: Tue, 24 Sep 2024 12:14:11 +0530 Subject: [PATCH] aDDING TOKEN INPUT PARAM --- setup-env/action.yml | 3 +++ setup-env/config/constants.js | 1 + setup-env/src/actionInput/index.js | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/setup-env/action.yml b/setup-env/action.yml index 4b8f8e7..3e3a299 100644 --- a/setup-env/action.yml +++ b/setup-env/action.yml @@ -13,6 +13,9 @@ inputs: project-name: description: 'Project name for the tests' required: false + github-token: + description: 'BrowserStack Github Token' + required: false github-app: description: 'BrowserStack Github App' required: false diff --git a/setup-env/config/constants.js b/setup-env/config/constants.js index fb0cdb9..f53a8a4 100644 --- a/setup-env/config/constants.js +++ b/setup-env/config/constants.js @@ -5,6 +5,7 @@ module.exports = { BUILD_NAME: 'build-name', PROJECT_NAME: 'project-name', GITHUB_APP: 'github-app', + GITHUB_TOKEN: 'github-token', }, ENV_VARS: { diff --git a/setup-env/src/actionInput/index.js b/setup-env/src/actionInput/index.js index 797d049..8f1c7ce 100644 --- a/setup-env/src/actionInput/index.js +++ b/setup-env/src/actionInput/index.js @@ -36,6 +36,7 @@ class ActionInput { this.rerunAttempt = process?.env?.GITHUB_RUN_ATTEMPT; this.runId = process?.env?.GITHUB_RUN_ID; this.repository = process?.env?.GITHUB_REPOSITORY; + this.githubToken = core.getInput(INPUT.GITHUB_TOKEN); } catch (e) { throw Error(`Action input failed for reason: ${e.message}`); } @@ -95,12 +96,11 @@ class ActionInput { async identifyRunFromBStack() { try { - const githubToken = process.env.GITHUB_TOKEN; const runDetailsUrl = `https://api.github.com/repos/${this.repository}/actions/runs/${this.runId}`; - core.info(`Github token is - ${githubToken} and url is - ${runDetailsUrl}`); + core.info(`Github token is - ${this.githubToken} and url is - ${runDetailsUrl}`); const runDetailsResponse = await axios.get(runDetailsUrl, { headers: { - Authorization: `token ${githubToken}`, + Authorization: `token ${this.githubToken}`, Accept: 'application/vnd.github.v3+json', }, });