diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-03-29 12:45:29 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-03-29 23:42:14 +0200 |
commit | 6cd4eefd9270354e3554c2200bd3c8a96959508c (patch) | |
tree | 747cb39f9452581b2d111615c7062fa61d22a959 /scripts | |
parent | e10214a726885e5f51a9a1e157fa5e36e19eadc3 (diff) | |
download | qutebrowser-6cd4eefd9270354e3554c2200bd3c8a96959508c.tar.gz qutebrowser-6cd4eefd9270354e3554c2200bd3c8a96959508c.zip |
scripts: Use GITHUB_TOKEN for 3rdparty updates
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/dev/update_3rdparty.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/scripts/dev/update_3rdparty.py b/scripts/dev/update_3rdparty.py index dc1c4f289..76f77303c 100755 --- a/scripts/dev/update_3rdparty.py +++ b/scripts/dev/update_3rdparty.py @@ -71,8 +71,16 @@ def get_latest_pdfjs_url(): """ github_api = 'https://api.github.com' endpoint = 'repos/mozilla/pdf.js/releases/latest' - request_url = '{}/{}'.format(github_api, endpoint) - with urllib.request.urlopen(request_url) as fp: + request = urllib.request.Request(f'{github_api}/{endpoint}') + + token = os.environ.get('GITHUB_TOKEN') + if token is not None: + # Without token will work as well, but has a strict rate limit, so we need to + # use the token on CI. + request.add_header('Authorization', f'token {token}') + print("Using GITHUB_TOKEN to authorize to GitHub.") + + with urllib.request.urlopen(request) as fp: data = json.loads(fp.read().decode('utf-8')) download_url = data['assets'][0]['browser_download_url'] |