@@ -3,24 +3,37 @@ import { endGroup, getInput, startGroup } from '@actions/core'
33import { context , getOctokit } from '@actions/github'
44import { retry } from '@octokit/plugin-retry'
55import { Md5 } from 'ts-md5'
6- import { DefaultArtifactClient , UploadArtifactResponse } from '@actions/artifact'
6+ import {
7+ Artifact ,
8+ DefaultArtifactClient ,
9+ DownloadArtifactOptions ,
10+ GetArtifactResponse ,
11+ UploadArtifactResponse ,
12+ } from '@actions/artifact'
713
814const artifact = new DefaultArtifactClient ( )
915
10- export function uploadArtifact (
11- artifactName : string ,
12- ...files : string [ ]
13- ) : Promise < UploadArtifactResponse > {
16+ export async function uploadArtifact ( artifactName : string , ...files : string [ ] ) {
1417 startGroup ( 'Uploading artifact ' + artifactName )
15- var reponse = artifact . uploadArtifact ( artifactName , files , '.' )
18+ await artifact . uploadArtifact ( artifactName , files , '.' )
1619 endGroup ( )
17- return reponse
1820}
1921
20- export async function downloadArtifact ( artifactName : string ) {
22+ export async function downloadArtifact ( artifactName : string ) : Promise < string > {
2123 startGroup ( 'Downloading artifact ' + artifactName )
22- await create . getArtifact ( artifactName )
24+ const getReponse : GetArtifactResponse = await artifact . getArtifact ( artifactName )
25+ const option : DownloadArtifactOptions = {
26+ path : path . join ( process . env [ 'GITHUB_WORKSPACE' ] , artifactName ) ,
27+ }
28+ const downloadReponse : DownloadArtifactOptions = await artifact . downloadArtifact (
29+ getReponse . artifact . id ,
30+ option
31+ )
32+ if ( downloadReponse . downloadPath === undefined ) {
33+ throw new Error ( 'Failed to download artifact ' + artifactName )
34+ }
2335 endGroup ( )
36+ return downloadReponse . downloadPath
2437}
2538
2639export async function postCommentIfInPr ( message : string ) : Promise < string | undefined > {
0 commit comments