Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions _scripts/generate-release-notes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,21 @@ def build_frontmatter

# Download the image from GitHub and save locally
def download_image(url, basename)
# Download and save file, some Github urls such as
# https://github.com/org/proj/assets/UUID require a
# redirect to be resolved to an valid AWS image url
res = Net::HTTP.get_response(URI(url))
case res
when Net::HTTPSuccess
image = Net::HTTP.get(URI(url))
when Net::HTTPRedirection
location = res['Location']
url = location
image = Net::HTTP.get(URI(location))
end

extension = url.split('.').last
filename = "#{basename}.#{extension}"

# Download and save file
image = Net::HTTP.get(URI(url))
File.write("images/#{filename}", image)

@files_images.push("images/#{filename}")
Expand Down