-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new option to specify behavior if no files found (#104)
* Add new option to specify behavior if no files found
- Loading branch information
Konrad Pabjan
authored and
GitHub
committed
Jul 31, 2020
1 parent
5f948bc
commit 5ba29a7
Showing
7 changed files
with
188 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
export enum Inputs { | ||
Name = 'name', | ||
Path = 'path' | ||
Path = 'path', | ||
IfNoFilesFound = 'if-no-files-found' | ||
} | ||
|
||
export function getDefaultArtifactName(): string { | ||
return 'artifact' | ||
export enum NoFileOptions { | ||
/** | ||
* 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' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |