Add new option to specify behavior if no files found (#104)
* Add new option to specify behavior if no files foundpull/108/head
parent
5f948bc1f0
commit
5ba29a7d5b
@ -1,8 +1,22 @@
|
|||||||
export enum Inputs {
|
export enum Inputs {
|
||||||
Name = 'name',
|
Name = 'name',
|
||||||
Path = 'path'
|
Path = 'path',
|
||||||
|
IfNoFilesFound = 'if-no-files-found'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDefaultArtifactName(): string {
|
export enum NoFileOptions {
|
||||||
return 'artifact'
|
/**
|
||||||
|
* Default. Output a warning but do not fail the action
|
||||||
|
*/
|
||||||
|
warn = 'warn',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fail the action with an error message
|
||||||
|
*/
|
||||||
|
error = 'error',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not output any warnings or errors, the action does not fail
|
||||||
|
*/
|
||||||
|
ignore = 'ignore'
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
import {NoFileOptions} from './constants'
|
||||||
|
|
||||||
|
export interface UploadInputs {
|
||||||
|
/**
|
||||||
|
* The name of the artifact that will be uploaded
|
||||||
|
*/
|
||||||
|
artifactName: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The search path used to describe what to upload as part of the artifact
|
||||||
|
*/
|
||||||
|
searchPath: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The desired behavior if no files are found with the provided search path
|
||||||
|
*/
|
||||||
|
ifNoFilesFound: NoFileOptions
|
||||||
|
}
|
Loading…
Reference in New Issue