Skip to content

@actions/artifact: Support custom Octokit client #2035

Open
@int128

Description

@int128

Describe the enhancement
downloadArtifact function does not retry if GitHub API returned an error such as status 500. This is because the Octokit client is hardcoded as below:

const api = github.getOctokit(token)
let digestMismatch = false
core.info(
`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`
)
const {headers, status} = await api.rest.actions.downloadArtifact({
owner: repositoryOwner,
repo: repositoryName,
artifact_id: artifactId,
archive_format: 'zip',
request: {
redirect: 'manual'
}
})

It would be nice if downloadArtifact function supports an option to pass an Octokit client. Here is an example snippet:

import * as github from '@actions/github'
import { retry } from '@octokit/plugin-retry'
import { DefaultArtifactClient } from '@actions/artifact'

const example = () => {
  const octokit = github.getOctokit(token, {}, retry)

  const artifactClient = new DefaultArtifactClient()
  artifactClient.downloadArtifact(artifactId, {
    path: 'example-directory',
    findBy: {
      workflowRunId: workflowRunId,
      repositoryOwner: github.context.repo.owner,
      repositoryName: github.context.repo.repo,
      octokit: octokit,
    },
  })
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions