diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 884c169ed2..b28410150e 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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 diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index eb3ec64543..9ab210b630 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -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