mirror of
https://github.com/actions/upload-artifact.git
synced 2025-06-29 04:14:15 +00:00
Added support for uploading multiple artifacts
This commit is contained in:
parent
ee69f02b3d
commit
0b90c2eee6
4 changed files with 178 additions and 109 deletions
|
@ -9,6 +9,18 @@ export function getInputs(): UploadInputs {
|
|||
const name = core.getInput(Inputs.Name)
|
||||
const path = core.getInput(Inputs.Path, {required: true})
|
||||
|
||||
const searchPath = Array.isArray(path) ? path : [path]
|
||||
|
||||
const defaultArtifactName = 'artifact'
|
||||
// Accepts an individual value or an array as input, if array sizes don't match, use default value instead
|
||||
const artifactName = Array.isArray(name)
|
||||
? name.concat(
|
||||
new Array(Math.max(0, searchPath.length - name.length)).fill(
|
||||
defaultArtifactName
|
||||
)
|
||||
)
|
||||
: new Array(searchPath.length).fill(name || defaultArtifactName)
|
||||
|
||||
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
|
||||
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
|
||||
|
||||
|
@ -23,18 +35,40 @@ export function getInputs(): UploadInputs {
|
|||
}
|
||||
|
||||
const inputs = {
|
||||
artifactName: name,
|
||||
searchPath: path,
|
||||
artifactName,
|
||||
searchPath,
|
||||
ifNoFilesFound: noFileBehavior
|
||||
} as UploadInputs
|
||||
|
||||
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
||||
if (retentionDaysStr) {
|
||||
inputs.retentionDays = parseInt(retentionDaysStr)
|
||||
if (isNaN(inputs.retentionDays)) {
|
||||
core.setFailed('Invalid retention-days')
|
||||
}
|
||||
// Accepts an individual value or an array as input
|
||||
const retentionDays = core.getInput(Inputs.RetentionDays)
|
||||
if (Array.isArray(retentionDays)) {
|
||||
// If array sizes don't match, use default value instead
|
||||
inputs.retentionDays = retentionDays
|
||||
.map(parseRetentionDays)
|
||||
.concat(
|
||||
new Array(Math.max(0, searchPath.length - retentionDays.length)).fill(
|
||||
undefined
|
||||
)
|
||||
)
|
||||
} else {
|
||||
const retention = parseRetentionDays(retentionDays)
|
||||
inputs.retentionDays = new Array(searchPath.length).fill(retention)
|
||||
}
|
||||
|
||||
return inputs
|
||||
}
|
||||
|
||||
function parseRetentionDays(
|
||||
retentionDaysStr: string | undefined
|
||||
): number | undefined {
|
||||
if (retentionDaysStr) {
|
||||
const retentionDays = parseInt(retentionDaysStr)
|
||||
if (isNaN(retentionDays)) {
|
||||
core.setFailed('Invalid retention-days')
|
||||
}
|
||||
return retentionDays
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue