V2 Download Artifact (#27)

* V2 Preview (#19)

* V2 Setup

* Add end-to-end tests

* Update tests

* Update tests

* Update tests

* Update tests again

* Misc Updates

* Improve logs

* Update release

* Update README.md

* @actions/artifact v0.2.0

* Update to the latest version of the @actions/artifact package

* Update @actions/artifact to 0.3.1

* Misc Updates

* Add .gitattributes

* Update Readme

* Update test YAML
This commit is contained in:
Konrad Pabjan 2020-04-28 15:45:21 +02:00 committed by GitHub
parent b85295d276
commit 1de1dea89c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 10573 additions and 15 deletions

4
src/constants.ts Normal file
View file

@ -0,0 +1,4 @@
export enum Inputs {
Name = 'name',
Path = 'path'
}

40
src/download-artifact.ts Normal file
View file

@ -0,0 +1,40 @@
import * as core from '@actions/core'
import * as artifact from '@actions/artifact'
import {Inputs} from './constants'
async function run(): Promise<void> {
try {
const name = core.getInput(Inputs.Name, {required: false})
const path = core.getInput(Inputs.Path, {required: false})
const artifactClient = artifact.create()
if (!name) {
// download all artifacts
const downloadResponse = await artifactClient.downloadAllArtifacts(path)
core.info(`There were ${downloadResponse.length} artifacts downloaded`)
for (const artifact of downloadResponse) {
core.info(
`Artifact ${artifact.artifactName} was downloaded to ${artifact.downloadPath}`
)
}
} else {
// download a single artifact
const downloadOptions = {
createArtifactFolder: false
}
const downloadResponse = await artifactClient.downloadArtifact(
name,
path,
downloadOptions
)
core.info(
`Artifact ${downloadResponse.artifactName} was downloaded to ${downloadResponse.downloadPath}`
)
}
core.info('Artifact download has finished successfully')
} catch (err) {
core.setFailed(err.message)
}
}
run()