@@ -50,33 +50,17 @@ export async function downloadArtifact(
50
50
const headers = {
51
51
Authorization : `Bearer ${ token } `
52
52
}
53
- const resp = await got ( req . url , {
54
- headers,
55
- followRedirect : false
56
- } )
57
-
58
- core . info ( `Fetch artifact URL: ${ resp . statusCode } ${ resp . statusMessage } ` )
59
- if ( resp . statusCode !== 302 ) {
60
- throw new Error ( 'Fetch artifact URL failed: received unexpected status code' )
61
- }
62
-
63
- const url = resp . headers . location
64
- if ( url === undefined ) {
65
- const receivedHeaders = Object . keys ( resp . headers )
66
- core . info ( `Received headers: ${ receivedHeaders . join ( ', ' ) } ` )
67
- throw new Error ( 'Location header was not found in API response' )
68
- }
69
- if ( typeof url !== 'string' ) {
70
- throw new Error ( `Location header has unexpected value: ${ url } ` )
71
- }
72
53
73
- const downloadStream = got . stream ( url , { headers} )
54
+ const downloadStream = got . stream ( req . url , { headers} )
74
55
const fileWriterStream = createWriteStream ( fileName )
75
56
76
- core . info ( `Downloading ${ url } ` )
57
+ downloadStream . on ( 'redirect' , response => {
58
+ core . info ( `Downloading ${ response . headers . location } ` )
59
+ } )
77
60
downloadStream . on ( 'downloadProgress' , ( { transferred} ) => {
78
61
core . info ( `Progress: ${ transferred } B` )
79
62
} )
63
+
80
64
await asyncStream ( downloadStream , fileWriterStream )
81
65
} finally {
82
66
core . endGroup ( )
0 commit comments