mirror of
https://github.com/actions/upload-artifact.git
synced 2024-11-22 19:22:50 +00:00
31 lines
786 B
TypeScript
31 lines
786 B
TypeScript
|
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})
|
||
|
|
||
|
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
|
||
|
)}`
|
||
|
)
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
artifactName: name,
|
||
|
searchPath: path,
|
||
|
ifNoFilesFound: noFileBehavior
|
||
|
}
|
||
|
}
|