consume latest @actions/toolkit (#461)

This commit is contained in:
Rob Herley
2023-12-07 14:53:07 -05:00
committed by GitHub
parent 500e175644
commit eba2a242da
2 changed files with 115 additions and 154 deletions

View File

@ -1,7 +1,6 @@
import * as core from '../node_modules/@actions/core/'
import {
UploadArtifactOptions,
create
import artifact, {
UploadArtifactOptions
} from '../node_modules/@actions/artifact/lib/artifact'
import {findFilesToUpload} from './search'
import {getInputs} from './input-helper'
@ -40,7 +39,6 @@ async function run(): Promise<void> {
)
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
const artifactClient = create()
const options: UploadArtifactOptions = {}
if (inputs.retentionDays) {
options.retentionDays = inputs.retentionDays
@ -50,23 +48,17 @@ async function run(): Promise<void> {
options.compressionLevel = inputs.compressionLevel
}
const uploadResponse = await artifactClient.uploadArtifact(
const uploadResponse = await artifact.uploadArtifact(
inputs.artifactName,
searchResult.filesToUpload,
searchResult.rootDirectory,
options
)
if (uploadResponse.success === false) {
core.setFailed(
`An error was encountered when uploading ${inputs.artifactName}.`
)
} else {
core.info(
`Artifact ${inputs.artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`
)
core.setOutput('artifact-id', uploadResponse.id)
}
core.info(
`Artifact ${inputs.artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`
)
core.setOutput('artifact-id', uploadResponse.id)
}
} catch (error) {
core.setFailed((error as Error).message)