mirror of
https://code.forgejo.org/forgejo/download-artifact.git
synced 2025-05-16 20:27:48 +02:00
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:
parent
b85295d276
commit
1de1dea89c
15 changed files with 10573 additions and 15 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