diff --git a/dist/index.js b/dist/index.js index 7e2a109..1db947c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5553,7 +5553,7 @@ function run() { const unsignedUrl = `${response.data.value[0].url}`; console.log(response.data); console.log(`unsigned artifact url is ${unsignedUrl}`); - if (!process.env.GITHUB_TOKEN) { + if (!inputs.token) { console.log("missing github token"); } else { @@ -5564,7 +5564,7 @@ function run() { headers: { "Accept": "application/vnd.github.v3+json", "Content-Type": "application/json", - "Authorization": `Bearer ${process.env.GITHUB_TOKEN}` + "Authorization": `Bearer ${inputs.token}}` } }); console.log(response.data); @@ -9113,6 +9113,7 @@ const constants_1 = __webpack_require__(694); function getInputs() { const name = core.getInput(constants_1.Inputs.Name); const path = core.getInput(constants_1.Inputs.Path, { required: true }); + const token = core.getInput(constants_1.Inputs.Token); const ifNoFilesFound = core.getInput(constants_1.Inputs.IfNoFilesFound); const noFileBehavior = constants_1.NoFileOptions[ifNoFilesFound]; if (!noFileBehavior) { @@ -9121,7 +9122,8 @@ function getInputs() { const inputs = { artifactName: name, searchPath: path, - ifNoFilesFound: noFileBehavior + ifNoFilesFound: noFileBehavior, + token: token }; const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays); if (retentionDaysStr) { @@ -10729,6 +10731,7 @@ var Inputs; (function (Inputs) { Inputs["Name"] = "name"; Inputs["Path"] = "path"; + Inputs["Token"] = "token"; Inputs["IfNoFilesFound"] = "if-no-files-found"; Inputs["RetentionDays"] = "retention-days"; })(Inputs = exports.Inputs || (exports.Inputs = {})); diff --git a/src/constants.ts b/src/constants.ts index 894ff4c..0d3559b 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,6 +1,7 @@ export enum Inputs { Name = 'name', Path = 'path', + Token = 'token', IfNoFilesFound = 'if-no-files-found', RetentionDays = 'retention-days' } diff --git a/src/input-helper.ts b/src/input-helper.ts index 8344823..2927ed9 100644 --- a/src/input-helper.ts +++ b/src/input-helper.ts @@ -8,6 +8,7 @@ import {UploadInputs} from './upload-inputs' export function getInputs(): UploadInputs { const name = core.getInput(Inputs.Name) const path = core.getInput(Inputs.Path, {required: true}) + const token = core.getInput(Inputs.Token) const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound) const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound] @@ -25,7 +26,8 @@ export function getInputs(): UploadInputs { const inputs = { artifactName: name, searchPath: path, - ifNoFilesFound: noFileBehavior + ifNoFilesFound: noFileBehavior, + token: token } as UploadInputs const retentionDaysStr = core.getInput(Inputs.RetentionDays) diff --git a/src/upload-artifact.ts b/src/upload-artifact.ts index 644023d..e3566f1 100644 --- a/src/upload-artifact.ts +++ b/src/upload-artifact.ts @@ -78,7 +78,7 @@ async function run(): Promise { const unsignedUrl = `${response.data.value[0].url}` console.log(response.data) console.log(`unsigned artifact url is ${unsignedUrl}`) - if (!process.env.GITHUB_TOKEN) { + if (!inputs.token) { console.log("missing github token") } else { response = await axios.post("https://api.github.com/repos/github/hub/pages/deployment", { @@ -88,7 +88,7 @@ async function run(): Promise { headers: { "Accept": "application/vnd.github.v3+json", "Content-Type": "application/json", - "Authorization": `Bearer ${process.env.GITHUB_TOKEN}` + "Authorization": `Bearer ${inputs.token}}` } }) console.log(response.data) diff --git a/src/upload-inputs.ts b/src/upload-inputs.ts index 37325df..d803f75 100644 --- a/src/upload-inputs.ts +++ b/src/upload-inputs.ts @@ -20,4 +20,6 @@ export interface UploadInputs { * Duration after which artifact will expire in days */ retentionDays: number + + token: string }