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' description: 'Upload a build artifact that can be used by subsequent workflow steps'
author: 'GitHub' author: 'GitHub'
inputs: inputs:
name:
description: 'Artifact name'
default: 'artifact'
path: path:
description: 'A file, directory or wildcard pattern that describes what to upload' description: 'A file, directory or wildcard pattern that describes what to upload'
required: true required: true

6
dist/index.js vendored
View File

@ -4019,7 +4019,8 @@ function run() {
const options = { const options = {
continueOnError: false continueOnError: false
}; };
const uploadResponse = yield artifactClient.uploadArtifact(inputs.artifactName, searchResult.filesToUpload, searchResult.rootDirectory, options); for (const file of searchResult.filesToUpload) {
const uploadResponse = yield artifactClient.uploadArtifact(file, [file], searchResult.rootDirectory, options);
if (uploadResponse.failedItems.length > 0) { 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.`); core.setFailed(`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`);
} }
@ -4028,6 +4029,7 @@ function run() {
} }
} }
} }
}
catch (err) { catch (err) {
core.setFailed(err.message); core.setFailed(err.message);
} }
@ -6383,7 +6385,6 @@ const constants_1 = __webpack_require__(694);
* Helper to get all the inputs for the action * Helper to get all the inputs for the action
*/ */
function getInputs() { function getInputs() {
const name = core.getInput(constants_1.Inputs.Name);
const path = core.getInput(constants_1.Inputs.Path, { required: true }); const path = core.getInput(constants_1.Inputs.Path, { required: true });
const ifNoFilesFound = core.getInput(constants_1.Inputs.IfNoFilesFound); const ifNoFilesFound = core.getInput(constants_1.Inputs.IfNoFilesFound);
const noFileBehavior = constants_1.NoFileOptions[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)}`); core.setFailed(`Unrecognized ${constants_1.Inputs.IfNoFilesFound} input. Provided: ${ifNoFilesFound}. Available options: ${Object.keys(constants_1.NoFileOptions)}`);
} }
return { return {
artifactName: name,
searchPath: path, searchPath: path,
ifNoFilesFound: noFileBehavior ifNoFilesFound: noFileBehavior
}; };

View File

@ -6,7 +6,6 @@ import {UploadInputs} from './upload-inputs'
* Helper to get all the inputs for the action * Helper to get all the inputs for the action
*/ */
export function getInputs(): UploadInputs { export function getInputs(): UploadInputs {
const name = core.getInput(Inputs.Name)
const path = core.getInput(Inputs.Path, {required: true}) const path = core.getInput(Inputs.Path, {required: true})
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound) const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
@ -23,7 +22,6 @@ export function getInputs(): UploadInputs {
} }
return { return {
artifactName: name,
searchPath: path, searchPath: path,
ifNoFilesFound: noFileBehavior ifNoFilesFound: noFileBehavior
} }

View File

@ -40,9 +40,11 @@ async function run(): Promise<void> {
const options: UploadOptions = { const options: UploadOptions = {
continueOnError: false continueOnError: false
} }
for (const file of searchResult.filesToUpload) {
const uploadResponse = await artifactClient.uploadArtifact( const uploadResponse = await artifactClient.uploadArtifact(
inputs.artifactName, file,
searchResult.filesToUpload, [file],
searchResult.rootDirectory, searchResult.rootDirectory,
options options
) )
@ -57,6 +59,7 @@ async function run(): Promise<void> {
) )
} }
} }
}
} catch (err) { } catch (err) {
core.setFailed(err.message) core.setFailed(err.message)
} }

View File

@ -1,11 +1,6 @@
import {NoFileOptions} from './constants' import {NoFileOptions} from './constants'
export interface UploadInputs { 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 * The search path used to describe what to upload as part of the artifact
*/ */