Upload multiple artifacts

This commit is contained in:
darkkeks 2020-09-02 01:27:15 +03:00
parent 58740802ef
commit 64a16cb7f4
5 changed files with 24 additions and 31 deletions

View File

@ -2,9 +2,6 @@ name: 'Upload a Build Artifact'
description: 'Upload a build artifact that can be used by subsequent workflow steps'
author: 'GitHub'
inputs:
name:
description: 'Artifact name'
default: 'artifact'
path:
description: 'A file, directory or wildcard pattern that describes what to upload'
required: true

16
dist/index.js vendored
View File

@ -4019,12 +4019,14 @@ function run() {
const options = {
continueOnError: false
};
const uploadResponse = yield artifactClient.uploadArtifact(inputs.artifactName, searchResult.filesToUpload, searchResult.rootDirectory, options);
if (uploadResponse.failedItems.length > 0) {
core.setFailed(`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`);
}
else {
core.info(`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`);
for (const file of searchResult.filesToUpload) {
const uploadResponse = yield artifactClient.uploadArtifact(file, [file], searchResult.rootDirectory, options);
if (uploadResponse.failedItems.length > 0) {
core.setFailed(`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`);
}
else {
core.info(`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`);
}
}
}
}
@ -6383,7 +6385,6 @@ const constants_1 = __webpack_require__(694);
* Helper to get all the inputs for the action
*/
function getInputs() {
const name = core.getInput(constants_1.Inputs.Name);
const path = core.getInput(constants_1.Inputs.Path, { required: true });
const ifNoFilesFound = core.getInput(constants_1.Inputs.IfNoFilesFound);
const noFileBehavior = constants_1.NoFileOptions[ifNoFilesFound];
@ -6391,7 +6392,6 @@ function getInputs() {
core.setFailed(`Unrecognized ${constants_1.Inputs.IfNoFilesFound} input. Provided: ${ifNoFilesFound}. Available options: ${Object.keys(constants_1.NoFileOptions)}`);
}
return {
artifactName: name,
searchPath: path,
ifNoFilesFound: noFileBehavior
};

View File

@ -6,7 +6,6 @@ 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)
@ -23,7 +22,6 @@ export function getInputs(): UploadInputs {
}
return {
artifactName: name,
searchPath: path,
ifNoFilesFound: noFileBehavior
}

View File

@ -40,21 +40,24 @@ async function run(): Promise<void> {
const options: UploadOptions = {
continueOnError: false
}
const uploadResponse = await artifactClient.uploadArtifact(
inputs.artifactName,
searchResult.filesToUpload,
searchResult.rootDirectory,
options
)
if (uploadResponse.failedItems.length > 0) {
core.setFailed(
`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`
)
} else {
core.info(
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
for (const file of searchResult.filesToUpload) {
const uploadResponse = await artifactClient.uploadArtifact(
file,
[file],
searchResult.rootDirectory,
options
)
if (uploadResponse.failedItems.length > 0) {
core.setFailed(
`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`
)
} else {
core.info(
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
)
}
}
}
} catch (err) {

View File

@ -1,11 +1,6 @@
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
*/