GitHubArtifactDownloadStrategy: fix initialize signature

This commit is contained in:
Carlo Cabrera 2023-05-17 12:58:31 +08:00
parent ee6ef00a73
commit 9260bd97e8
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 6 additions and 12 deletions

View File

@ -637,9 +637,10 @@ end
#
# @api private
class GitHubArtifactDownloadStrategy < AbstractFileDownloadStrategy
def initialize
super
def initialize(url, artifact_id, token:)
super(url, "artifact", artifact_id)
@cache = HOMEBREW_CACHE/"gh-actions-artifact"
@token = token
end
def fetch(timeout: nil)
@ -649,8 +650,8 @@ class GitHubArtifactDownloadStrategy < AbstractFileDownloadStrategy
else
begin
curl "--location", "--create-dirs", "--output", temporary_path, url,
*meta.fetch(:curl_args, []),
secrets: meta.fetch(:secrets, []),
"--header", "Authorization: token #{@token}",
secrets: [@token],
timeout: timeout
rescue ErrorDuringExecution
raise CurlDownloadStrategyError, url

View File

@ -383,18 +383,11 @@ module GitHub
odie "Credentials must be set to access the Artifacts API" if API.credentials_type == :none
token = API.credentials
curl_args = ["--header", "Authorization: token #{token}"]
# Download the artifact as a zip file and unpack it into `dir`. This is
# preferred over system `curl` and `tar` as this leverages the Homebrew
# cache to avoid repeated downloads of (possibly large) bottles.
downloader = GitHubArtifactDownloadStrategy.new(
url,
"artifact",
artifact_id,
curl_args: curl_args,
secrets: [token],
)
downloader = GitHubArtifactDownloadStrategy.new(url, artifact_id, token: token)
downloader.fetch
downloader.stage
end