diff --git a/src/input-providers/artifact-provider.ts b/src/input-providers/artifact-provider.ts index f91a002..5222bbc 100644 --- a/src/input-providers/artifact-provider.ts +++ b/src/input-providers/artifact-provider.ts @@ -1,6 +1,6 @@ import * as core from '@actions/core' import * as github from '@actions/github' -import {GitHub} from '@actions/github/lib/utils.js' +import {GitHub} from '@actions/github/lib/utils' import Zip from 'adm-zip' import picomatch from 'picomatch' @@ -8,6 +8,11 @@ import picomatch from 'picomatch' import {FileContent, InputProvider, ReportInput} from './input-provider.js' import {downloadArtifact, listFiles} from '../utils/github-utils.js' +type WorkflowRunArtifact = { + id: number + name: string +} + export class ArtifactProvider implements InputProvider { private readonly artifactNameMatch: (name: string) => boolean private readonly fileNameMatch: (name: string) => boolean @@ -50,10 +55,10 @@ export class ArtifactProvider implements InputProvider { async load(): Promise { const result: ReportInput = {} - const allArtifacts = await this.octokit.paginate(this.octokit.rest.actions.listWorkflowRunArtifacts, { + const allArtifacts = (await this.octokit.paginate(this.octokit.rest.actions.listWorkflowRunArtifacts, { ...github.context.repo, run_id: this.runId - }) + })) as WorkflowRunArtifact[] if (allArtifacts.length === 0) { core.warning(`No artifacts found in run ${this.runId}`) diff --git a/src/main.ts b/src/main.ts index 2734ee8..888fd73 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,6 @@ import * as core from '@actions/core' import * as github from '@actions/github' -import {GitHub} from '@actions/github/lib/utils.js' +import {GitHub} from '@actions/github/lib/utils' import {ArtifactProvider} from './input-providers/artifact-provider.js' import {LocalFileProvider} from './input-providers/local-file-provider.js' diff --git a/src/utils/github-utils.ts b/src/utils/github-utils.ts index 74b2d51..eafeb4e 100644 --- a/src/utils/github-utils.ts +++ b/src/utils/github-utils.ts @@ -3,7 +3,7 @@ import {pipeline} from 'stream/promises' import {Readable, Transform} from 'stream' import * as core from '@actions/core' import * as github from '@actions/github' -import {GitHub} from '@actions/github/lib/utils.js' +import {GitHub} from '@actions/github/lib/utils' import type {PullRequest, WorkflowRunEvent} from '@octokit/webhooks-types' export function getCheckRunContext(): {sha: string; runId: number} { @@ -125,7 +125,11 @@ async function listGitTree(octokit: InstanceType, sha: string, pa if (tr.type === 'blob') { result.push(file) } else if (tr.type === 'tree' && truncated) { - const files = await listGitTree(octokit, tr.sha as string, `${file}/`) + if (!tr.sha) { + core.warning(`Skipping tree ${file}: missing SHA`) + continue + } + const files = await listGitTree(octokit, tr.sha, `${file}/`) result.push(...files) } }