mirror of
https://code.forgejo.org/forgejo/download-artifact.git
synced 2025-05-16 20:27:48 +02:00
Misc Download Artifact Improvements (#43)
* Various improvements to download-artifact * Resolve input path * README updates * PR feedback
This commit is contained in:
parent
385ad92b52
commit
7e5b6f00de
6 changed files with 286 additions and 125 deletions
|
@ -2,3 +2,6 @@ export enum Inputs {
|
|||
Name = 'name',
|
||||
Path = 'path'
|
||||
}
|
||||
export enum Outputs {
|
||||
DownloadPath = 'download-path'
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import * as core from '@actions/core'
|
||||
import * as artifact from '@actions/artifact'
|
||||
import {Inputs} from './constants'
|
||||
import {resolve} from 'path'
|
||||
import {Inputs, Outputs} from './constants'
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
|
@ -10,6 +11,10 @@ async function run(): Promise<void> {
|
|||
const artifactClient = artifact.create()
|
||||
if (!name) {
|
||||
// download all artifacts
|
||||
core.info('No artifact name specified, downloading all artifacts')
|
||||
core.info(
|
||||
'Creating an extra directory for each artifact that is being downloaded'
|
||||
)
|
||||
const downloadResponse = await artifactClient.downloadAllArtifacts(path)
|
||||
core.info(`There were ${downloadResponse.length} artifacts downloaded`)
|
||||
for (const artifact of downloadResponse) {
|
||||
|
@ -19,6 +24,7 @@ async function run(): Promise<void> {
|
|||
}
|
||||
} else {
|
||||
// download a single artifact
|
||||
core.info(`Starting download for ${name}`)
|
||||
const downloadOptions = {
|
||||
createArtifactFolder: false
|
||||
}
|
||||
|
@ -31,6 +37,9 @@ async function run(): Promise<void> {
|
|||
`Artifact ${downloadResponse.artifactName} was downloaded to ${downloadResponse.downloadPath}`
|
||||
)
|
||||
}
|
||||
// output the directory that the artifact(s) was/were downloaded to
|
||||
// if no path is provided, an empty string resolves to the current working directory
|
||||
core.setOutput(Outputs.DownloadPath, resolve(path))
|
||||
core.info('Artifact download has finished successfully')
|
||||
} catch (err) {
|
||||
core.setFailed(err.message)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue