Compare commits

..

2 Commits

Author SHA1 Message Date
Jozef Izso
6126f49c2c Use types arguments in the downloadStream event handlers
Issues #603
2025-06-08 13:21:12 +02:00
Jozef Izso
be2b975095 Use typed WorkflowRunEvent when parsing workflow_run payload
Issue #603
2025-06-08 13:21:12 +02:00
5 changed files with 13 additions and 13 deletions

View File

@@ -10,7 +10,6 @@
"rules": {
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/extensions": [ "error", "ignorePackages", { "ts": "never" } ],
"import/no-namespace": "off",
"import/no-named-as-default": "off",
"no-shadow": "off",

6
dist/index.js generated vendored
View File

@@ -2439,11 +2439,11 @@ async function downloadArtifact(octokit, artifactId, fileName, token) {
};
const downloadStream = got_1.default.stream(req.url, { headers });
const fileWriterStream = (0, fs_1.createWriteStream)(fileName);
downloadStream.on('redirect', response => {
downloadStream.on('redirect', (response) => {
core.info(`Downloading ${response.headers.location}`);
});
downloadStream.on('downloadProgress', ({ transferred }) => {
core.info(`Progress: ${transferred} B`);
downloadStream.on('downloadProgress', (progress) => {
core.info(`Progress: ${progress.transferred} B`);
});
await asyncStream(downloadStream, fileWriterStream);
}

View File

@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import type {GitHub} from '@actions/github/lib/utils.js'
import {GitHub} from '@actions/github/lib/utils'
import Zip from 'adm-zip'
import picomatch from 'picomatch'

View File

@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import type {GitHub} from '@actions/github/lib/utils.js'
import {GitHub} from '@actions/github/lib/utils'
import {ArtifactProvider} from './input-providers/artifact-provider'
import {LocalFileProvider} from './input-providers/local-file-provider'

View File

@@ -1,17 +1,18 @@
import {createWriteStream} from 'fs'
import * as core from '@actions/core'
import * as github from '@actions/github'
import type {GitHub} from '@actions/github/lib/utils.js'
import type {PullRequest} from '@octokit/webhooks-types'
import {GitHub} from '@actions/github/lib/utils'
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")
}
@@ -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)