@@ -2,16 +2,17 @@ import {createWriteStream} from 'fs'
22import * as core from '@actions/core'
33import * as github from '@actions/github'
44import { GitHub } from '@actions/github/lib/utils'
5- import type { PullRequest } from '@octokit/webhooks-types'
5+ import type { PullRequest , WorkflowRunEvent } from '@octokit/webhooks-types'
6+ import { IncomingMessage } from 'http'
67import * as stream from 'stream'
78import { promisify } from 'util'
8- import got from 'got'
9+ import got , { Progress } from 'got'
910const asyncStream = promisify ( stream . pipeline )
1011
1112export function getCheckRunContext ( ) : { sha : string ; runId : number } {
1213 if ( github . context . eventName === 'workflow_run' ) {
1314 core . info ( 'Action was triggered by workflow_run: using SHA and RUN_ID from triggering workflow' )
14- const event = github . context . payload
15+ const event = github . context . payload as WorkflowRunEvent
1516 if ( ! event . workflow_run ) {
1617 throw new Error ( "Event of type 'workflow_run' is missing 'workflow_run' field" )
1718 }
@@ -54,11 +55,11 @@ export async function downloadArtifact(
5455 const downloadStream = got . stream ( req . url , { headers} )
5556 const fileWriterStream = createWriteStream ( fileName )
5657
57- downloadStream . on ( 'redirect' , response => {
58+ downloadStream . on ( 'redirect' , ( response : IncomingMessage ) => {
5859 core . info ( `Downloading ${ response . headers . location } ` )
5960 } )
60- downloadStream . on ( 'downloadProgress' , ( { transferred } ) => {
61- core . info ( `Progress: ${ transferred } B` )
61+ downloadStream . on ( 'downloadProgress' , ( progress : Progress ) => {
62+ core . info ( `Progress: ${ progress . transferred } B` )
6263 } )
6364
6465 await asyncStream ( downloadStream , fileWriterStream )
0 commit comments