actions / actions/toolkit

@actions/artifact: Support custom Octokit client

Open
#2,035 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

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:

https://github.com/actions/toolkit/blob/1b1e81526b802d1d641911393281c2fb45ed5f11/packages/artifact/src/internal/download/download-artifact.ts#L131-L147

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,
    },
  })
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/artifact/src/internal/download/download-artifact.ts at the linked hardcoded Octokit client and trace the downloadArtifact options and findBy types. Check the existing artifact tests before making changes; done means callers can provide a custom Octokit client for artifact downloads and that the client is used for the GitHub API request.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, typescript
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.