Skip to content

Commit 56d957c

Browse files
committed
downloader: add support for GH_TOKEN for https://api.github.com/
1 parent 674e16c commit 56d957c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,7 @@ jobs:
6363
run: |
6464
bundle install
6565
- name: Test
66+
env:
67+
GH_TOKEN: ${{ github.token }}
6668
run: |
6769
bundle exec rake

lib/datasets/downloader.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ def download(output_path, &block)
168168
else
169169
request = Net::HTTP::Get.new(path, headers)
170170
end
171+
if url.scheme == "https" and url.host == "api.github.com"
172+
gh_token = ENV["GH_TOKEN"]
173+
if gh_token
174+
headers = headers.merge("Authorization" => "Bearer #{gh_token}")
175+
end
176+
end
171177
http.request(request) do |response|
172178
case response
173179
when Net::HTTPSuccess, Net::HTTPPartialContent

0 commit comments

Comments
 (0)