Skip to content

Commit 5456de9

Browse files
authored
Merge pull request #604 from dorny/feature/603_improve_code_quality
2 parents a6b3e93 + 6126f49 commit 5456de9

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

dist/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/github-utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import {createWriteStream} from 'fs'
22
import * as core from '@actions/core'
33
import * as github from '@actions/github'
44
import {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'
67
import * as stream from 'stream'
78
import {promisify} from 'util'
8-
import got from 'got'
9+
import got, {Progress} from 'got'
910
const asyncStream = promisify(stream.pipeline)
1011

1112
export 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

Comments
 (0)