Skip to content

Commit

Permalink
Merge pull request #604 from dorny/feature/603_improve_code_quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Izso authored and GitHub committed Jun 13, 2025
2 parents a6b3e93 + 6126f49 commit 5456de9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/utils/github-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import {createWriteStream} from 'fs'
import * as core from '@actions/core'
import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils'
import type {PullRequest} from '@octokit/webhooks-types'
import type {PullRequest, WorkflowRunEvent} from '@octokit/webhooks-types'
import {IncomingMessage} from 'http'
import * as stream from 'stream'
import {promisify} from 'util'
import got from 'got'
import got, {Progress} from 'got'
const asyncStream = promisify(stream.pipeline)

export function getCheckRunContext(): {sha: string; runId: number} {
if (github.context.eventName === 'workflow_run') {
core.info('Action was triggered by workflow_run: using SHA and RUN_ID from triggering workflow')
const event = github.context.payload
const event = github.context.payload as WorkflowRunEvent
if (!event.workflow_run) {
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
}
Expand Down Expand Up @@ -54,11 +55,11 @@ export async function downloadArtifact(
const downloadStream = got.stream(req.url, {headers})
const fileWriterStream = createWriteStream(fileName)

downloadStream.on('redirect', response => {
downloadStream.on('redirect', (response: IncomingMessage) => {
core.info(`Downloading ${response.headers.location}`)
})
downloadStream.on('downloadProgress', ({transferred}) => {
core.info(`Progress: ${transferred} B`)
downloadStream.on('downloadProgress', (progress: Progress) => {
core.info(`Progress: ${progress.transferred} B`)
})

await asyncStream(downloadStream, fileWriterStream)
Expand Down

0 comments on commit 5456de9

Please sign in to comment.