mirror of
https://code.forgejo.org/actions/upload-artifact.git
synced 2025-05-13 02:29:17 -04:00
Add new option to specify behavior if no files found (#104)
* Add new option to specify behavior if no files found
This commit is contained in:
parent
5f948bc1f0
commit
5ba29a7d5b
7 changed files with 188 additions and 25 deletions
30
src/input-helper.ts
Normal file
30
src/input-helper.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue