Class: GitHubArtifactDownloadStrategy Private
- Inherits:
-
AbstractFileDownloadStrategy
- Object
- AbstractDownloadStrategy
- AbstractFileDownloadStrategy
- GitHubArtifactDownloadStrategy
- Defined in:
- utils/github/artifacts.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Strategy for downloading an artifact from GitHub Actions.
Instance Attribute Summary
Attributes inherited from AbstractDownloadStrategy
#cache, #cached_location, #url
Instance Method Summary collapse
- #fetch(timeout: nil) ⇒ Object private
-
#initialize(url, artifact_id, token:) ⇒ GitHubArtifactDownloadStrategy
constructor
private
A new instance of GitHubArtifactDownloadStrategy.
Methods inherited from AbstractFileDownloadStrategy
#basename, #cached_location, #symlink_location, #temporary_path
Methods inherited from AbstractDownloadStrategy
#basename, #clear_cache, #quiet!, #quiet?, #shutup!, #source_modified_time, #stage
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Constructor Details
#initialize(url, artifact_id, token:) ⇒ GitHubArtifactDownloadStrategy
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a new instance of GitHubArtifactDownloadStrategy.
27 28 29 30 31 |
# File 'utils/github/artifacts.rb', line 27 def initialize(url, artifact_id, token:) super(url, "artifact", artifact_id) @cache = HOMEBREW_CACHE/"gh-actions-artifact" @token = token end |
Instance Method Details
#fetch(timeout: nil) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'utils/github/artifacts.rb', line 33 def fetch(timeout: nil) ohai "Downloading #{url}" if cached_location.exist? puts "Already downloaded: #{cached_location}" else begin Utils::Curl.curl("--location", "--create-dirs", "--output", temporary_path, url, "--header", "Authorization: token #{@token}", secrets: [@token], timeout:) rescue ErrorDuringExecution raise CurlDownloadStrategyError, url end ignore_interrupts do cached_location.dirname.mkpath temporary_path.rename(cached_location) symlink_location.dirname.mkpath end end FileUtils.ln_s cached_location.relative_path_from(symlink_location.dirname), symlink_location, force: true end |