Compare commits

...

14 Commits

Author SHA1 Message Date
Rob Herley 59db55461a
wip 2023-08-17 17:26:44 -04:00
Rob Herley 4047224a50
Merge branch 'main' into robherley/dl-artifact-tmp 2023-08-17 17:23:29 -04:00
Konrad Pabjan c803c0b02d PR cleanup 2023-08-17 14:19:19 -04:00
Konrad Pabjan 5fea8616de Simplify to id instead of ArtifactId 2023-08-17 14:09:52 -04:00
Konrad Pabjan d830aca920 Simplify to just name instead of artifactName 2023-08-17 14:03:25 -04:00
Konrad Pabjan 22298b02f4 Fix tsc error 2023-08-17 13:57:35 -04:00
Konrad Pabjan bd41eaf093 Cleanup download-all interfaces 2023-08-17 13:54:51 -04:00
Konrad Pabjan 814aedd45a Fix variables 2023-08-17 13:50:20 -04:00
Konrad Pabjan 8260ee063e Fix typo 2023-08-17 13:44:41 -04:00
Konrad Pabjan 800b0e5ae2 Improve list artifact test 2023-08-17 13:43:21 -04:00
Konrad Pabjan 6c90dc8898 Fix needs dependency 2023-08-17 13:22:17 -04:00
Konrad Pabjan e1f6cb00bd Test matrix strategy 2023-08-17 13:18:40 -04:00
Konrad Pabjan 6b96da32ae Merge branch 'main' into konradpabjan/download-artifact-next 2023-08-17 12:42:59 -04:00
Konrad Pabjan 2bccdbc690 actions/artifact preparation for download-artifact v4 2023-08-16 20:06:35 -04:00
2 changed files with 43 additions and 5 deletions

View File

@ -1,11 +1,11 @@
import {ArtifactClient, Client} from './internal/client'
import {UploadOptions, UploadResponse} from './internal/shared/interfaces'
/**
* Exported functionality that we want to expose for any users of @actions/artifact
*/
export {ArtifactClient, UploadOptions, UploadResponse}
export * from './internal/shared/interfaces'
export {ArtifactClient}
export function create(): ArtifactClient {
return Client.create()
}
}

View File

@ -1,7 +1,13 @@
import * as github from '@actions/github'
import * as core from '@actions/core'
import * as httpClient from '@actions/http-client'
import {
DownloadArtifactOptions,
DownloadArtifactResponse
} from '../shared/interfaces'
// import { getUserAgentString } from '../shared/user-agent'
// import * as unzipper from 'unzipper'
export async function downloadArtifact(
artifactId: number,
@ -10,5 +16,37 @@ export async function downloadArtifact(
token: string,
options?: DownloadArtifactOptions
): Promise<DownloadArtifactResponse> {
throw new Error('Not implemented')
}
const api = github.getOctokit(token)
core.info(`Downloading artifact ${artifactId} from ${repositoryOwner}/${repositoryName}`)
const {headers, status} = await api.rest.actions.downloadArtifact({
owner: repositoryOwner,
repo: repositoryName,
artifact_id: artifactId,
archive_format: 'zip',
request: {
redirect: 'manual',
},
})
if (status !== 302) {
throw new Error(`Unable to download artifact. Unexpected status: ${status}`)
}
const { location } = headers
if (!location) {
throw new Error(`Unable to redirect to artifact download url`)
}
const scrubbedURL = new URL(location);
scrubbedURL.search = ''
console.log(`Redirecting to blob download url: ${scrubbedURL.toString()}`)
// const client = new httpClient.HttpClient(getUserAgentString(), [], {})
// const response = await client.get(location)
// response.message.pipe(unzipper.Extract({ path: options?.path }))
return {success: true}
}