MCPcopy
hub / github.com/actions/download-artifact / run

Function run

src/download-artifact.ts:18–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16 }, [] as T[][])
17
18export async function run(): Promise<void> {
19 const inputs = {
20 name: core.getInput(Inputs.Name, {required: false}),
21 path: core.getInput(Inputs.Path, {required: false}),
22 token: core.getInput(Inputs.GitHubToken, {required: false}),
23 repository: core.getInput(Inputs.Repository, {required: false}),
24 runID: parseInt(core.getInput(Inputs.RunID, {required: false})),
25 pattern: core.getInput(Inputs.Pattern, {required: false}),
26 mergeMultiple: core.getBooleanInput(Inputs.MergeMultiple, {
27 required: false
28 }),
29 artifactIds: core.getInput(Inputs.ArtifactIds, {required: false}),
30 skipDecompress: core.getBooleanInput(Inputs.SkipDecompress, {
31 required: false
32 }),
33 digestMismatch: (core.getInput(Inputs.DigestMismatch, {required: false}) ||
34 DigestMismatchBehavior.Error) as DigestMismatchBehavior
35 }
36
37 // Validate digest-mismatch input
38 const validBehaviors = Object.values(DigestMismatchBehavior)
39 if (!validBehaviors.includes(inputs.digestMismatch)) {
40 throw new Error(
41 `Invalid value for 'digest-mismatch': '${inputs.digestMismatch}'. Valid options are: ${validBehaviors.join(', ')}`
42 )
43 }
44
45 if (!inputs.path) {
46 inputs.path = process.env['GITHUB_WORKSPACE'] || process.cwd()
47 }
48
49 if (inputs.path.startsWith(`~`)) {
50 inputs.path = inputs.path.replace('~', os.homedir())
51 }
52
53 // Check for mutually exclusive inputs
54 if (inputs.name && inputs.artifactIds) {
55 throw new Error(
56 `Inputs 'name' and 'artifact-ids' cannot be used together. Please specify only one.`
57 )
58 }
59
60 const isSingleArtifactDownload = !!inputs.name
61 const isDownloadByIds = !!inputs.artifactIds
62 const resolvedPath = path.resolve(inputs.path)
63 core.debug(`Resolved path is ${resolvedPath}`)
64
65 const options: FindOptions = {}
66 if (inputs.token) {
67 const [repositoryOwner, repositoryName] = inputs.repository.split('/')
68 if (!repositoryOwner || !repositoryName) {
69 throw new Error(
70 `Invalid repository: '${inputs.repository}'. Must be in format owner/repo`
71 )
72 }
73
74 options.findBy = {
75 token: inputs.token,

Callers 2

download.test.tsFile · 0.85

Calls 1

chunkFunction · 0.85

Tested by

no test coverage detected