2020-07-31 15:27:37 +00:00
|
|
|
import * as core from '@actions/core'
|
|
|
|
import {Inputs, NoFileOptions} from './constants'
|
|
|
|
import {UploadInputs} from './upload-inputs'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to get all the inputs for the action
|
|
|
|
*/
|
|
|
|
export function getInputs(): UploadInputs {
|
|
|
|
const name = core.getInput(Inputs.Name)
|
|
|
|
const path = core.getInput(Inputs.Path, {required: true})
|
2024-01-18 18:31:03 +00:00
|
|
|
const overwrite = core.getBooleanInput(Inputs.Overwrite)
|
2020-07-31 15:27:37 +00:00
|
|
|
|
|
|
|
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
|
|
|
|
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
|
|
|
|
|
|
|
|
if (!noFileBehavior) {
|
|
|
|
core.setFailed(
|
|
|
|
`Unrecognized ${
|
|
|
|
Inputs.IfNoFilesFound
|
|
|
|
} input. Provided: ${ifNoFilesFound}. Available options: ${Object.keys(
|
|
|
|
NoFileOptions
|
|
|
|
)}`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-27 17:39:36 +00:00
|
|
|
const inputs = {
|
2020-07-31 15:27:37 +00:00
|
|
|
artifactName: name,
|
|
|
|
searchPath: path,
|
2024-01-18 18:31:03 +00:00
|
|
|
ifNoFilesFound: noFileBehavior,
|
|
|
|
overwrite: overwrite
|
2020-08-27 17:39:36 +00:00
|
|
|
} as UploadInputs
|
|
|
|
|
|
|
|
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
|
|
|
if (retentionDaysStr) {
|
|
|
|
inputs.retentionDays = parseInt(retentionDaysStr)
|
2020-09-18 20:04:35 +00:00
|
|
|
if (isNaN(inputs.retentionDays)) {
|
|
|
|
core.setFailed('Invalid retention-days')
|
|
|
|
}
|
2020-07-31 15:27:37 +00:00
|
|
|
}
|
2020-08-27 17:39:36 +00:00
|
|
|
|
2023-11-20 16:08:50 +00:00
|
|
|
const compressionLevelStr = core.getInput(Inputs.CompressionLevel)
|
|
|
|
if (compressionLevelStr) {
|
|
|
|
inputs.compressionLevel = parseInt(compressionLevelStr)
|
|
|
|
if (isNaN(inputs.compressionLevel)) {
|
|
|
|
core.setFailed('Invalid compression-level')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inputs.compressionLevel < 0 || inputs.compressionLevel > 9) {
|
|
|
|
core.setFailed('Invalid compression-level. Valid values are 0-9')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-27 17:39:36 +00:00
|
|
|
return inputs
|
2020-07-31 15:27:37 +00:00
|
|
|
}
|