Compare commits

..

10 Commits

Author SHA1 Message Date
Rob Herley
d2e17e8b67 more patches 2023-12-09 17:24:52 -05:00
Rob Herley
621be0be95 swap unzipper with unzip-stream 2023-12-09 17:18:03 -05:00
Jonathan Tamsut
5be1d38671 Merge pull request #243 from actions/robherley/v4-beta-updates
Consume latest @actions/toolkit
2023-12-07 11:52:45 -08:00
Rob Herley
465b526e63 consume latest @actions/toolkit 2023-12-06 19:43:53 -05:00
Rob Herley
8b83831f82 Merge pull request #242 from actions/v4-beta-internal-client
Use internal client when `github-token` is not specified
2023-12-04 13:20:07 -05:00
Rob Herley
0742efc19b set new 'latest' attribute for list operations 2023-12-04 13:08:24 -05:00
Rob Herley
5e4b342272 consume latest @actions/artifact 2023-12-01 13:20:09 -05:00
Rob Herley
98c6f16055 Merge pull request #239 from actions/robherley/bump-v4-beta-toolkit
Bump to latest artifact version from toolkit
2023-11-21 10:58:42 -05:00
Rob Herley
9140050fd5 consume latest @actions/artifact from toolkit 2023-11-20 20:57:50 -05:00
Konrad Pabjan
88dadfbcfc [v4 beta] Fixes to download directory structure (#233)
* Fix extra root extra root directory if downloading single artifact on v4-beta

* Fix for all downloads

* Bump to node20 runtime

* ncc

---------

Co-authored-by: Rob Herley <robherley@github.com>
2023-10-27 10:11:07 -04:00
2 changed files with 2541 additions and 18224 deletions

20731
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,8 @@
import * as os from 'os'
import * as path from 'path'
import * as core from '@actions/core'
import * as artifact from '@actions/artifact'
import artifactClient from '@actions/artifact'
import type {Artifact, FindOptions} from '@actions/artifact'
import {Inputs, Outputs} from './constants'
const PARALLEL_DOWNLOADS = 5
@@ -30,10 +31,11 @@ async function run(): Promise<void> {
inputs.path = inputs.path.replace('~', os.homedir())
}
const isSingleArtifactDownload = !!inputs.name
const resolvedPath = path.resolve(inputs.path)
core.debug(`Resolved path is ${resolvedPath}`)
const options: artifact.FindOptions = {}
const options: FindOptions = {}
if (inputs.token) {
const [repositoryOwner, repositoryName] = inputs.repository.split('/')
if (!repositoryOwner || !repositoryName) {
@@ -50,10 +52,11 @@ async function run(): Promise<void> {
}
}
const artifactClient = artifact.create()
let artifacts: artifact.Artifact[] = []
let artifacts: Artifact[] = []
if (isSingleArtifactDownload) {
core.info(`Downloading single artifact`)
if (inputs.name) {
const {artifact: targetArtifact} = await artifactClient.getArtifact(
inputs.name,
options
@@ -63,12 +66,20 @@ async function run(): Promise<void> {
throw new Error(`Artifact '${inputs.name}' not found`)
}
core.debug('Found named artifact:')
core.debug(JSON.stringify(targetArtifact, null, 2))
core.debug(
`Found named artifact '${inputs.name}' (ID: ${targetArtifact.id}, Size: ${targetArtifact.size})`
)
artifacts = [targetArtifact]
} else {
const listArtifactResponse = await artifactClient.listArtifacts(options)
core.info(
`No input name specified, downloading all artifacts. Extra directory with the artifact name will be created for each download`
)
const listArtifactResponse = await artifactClient.listArtifacts({
latest: true,
...options
})
if (listArtifactResponse.artifacts.length === 0) {
throw new Error(
@@ -76,15 +87,16 @@ async function run(): Promise<void> {
)
}
core.debug(`Found ${listArtifactResponse.artifacts.length} artifacts:`)
core.debug(JSON.stringify(listArtifactResponse, null, 2))
core.debug(`Found ${listArtifactResponse.artifacts.length} artifacts`)
artifacts = listArtifactResponse.artifacts
}
const downloadPromises = artifacts.map(artifact =>
artifactClient.downloadArtifact(artifact.id, {
...options,
path: path.join(resolvedPath, artifact.name)
path: isSingleArtifactDownload
? resolvedPath
: path.join(resolvedPath, artifact.name)
})
)