mirror of
https://github.com/actions/upload-artifact.git
synced 2024-11-24 12:12:09 +00:00
97b7dace6c
* Use @actions/artifact 0.3.2 * setFailed if certain items don't upload * Update verion #
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import * as core from '@actions/core'
|
|
import {create, UploadOptions} from '@actions/artifact'
|
|
import {Inputs, getDefaultArtifactName} from './constants'
|
|
import {findFilesToUpload} from './search'
|
|
|
|
async function run(): Promise<void> {
|
|
try {
|
|
const name = core.getInput(Inputs.Name, {required: false})
|
|
const path = core.getInput(Inputs.Path, {required: true})
|
|
|
|
const searchResult = await findFilesToUpload(path)
|
|
if (searchResult.filesToUpload.length === 0) {
|
|
core.warning(
|
|
`No files were found for the provided path: ${path}. No artifacts will be uploaded.`
|
|
)
|
|
} else {
|
|
core.info(
|
|
`With the provided path, there will be ${searchResult.filesToUpload.length} files uploaded`
|
|
)
|
|
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
|
|
|
|
const artifactClient = create()
|
|
const options: UploadOptions = {
|
|
continueOnError: false
|
|
}
|
|
const uploadResponse = await artifactClient.uploadArtifact(
|
|
name || getDefaultArtifactName(),
|
|
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!`
|
|
)
|
|
}
|
|
}
|
|
} catch (err) {
|
|
core.setFailed(err.message)
|
|
}
|
|
}
|
|
|
|
run()
|