mirror of
https://code.forgejo.org/forgejo/download-artifact.git
synced 2025-06-08 17:55:42 +02:00
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
This commit is contained in:
parent
18f0f591fb
commit
3bdf740f02
14 changed files with 5313 additions and 12 deletions
4
src/constants.ts
Normal file
4
src/constants.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export enum Inputs {
|
||||
Name = 'name',
|
||||
Path = 'path'
|
||||
}
|
40
src/download-artifact.ts
Normal file
40
src/download-artifact.ts
Normal 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()
|
Loading…
Add table
Add a link
Reference in a new issue