aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-12-31 21:05:48 +0100
committerJay Berkenbilt <ejb@ql.org>2022-12-31 21:05:48 +0100
commit234e323743a48c3818313c887d029233fd210a15 (patch)
treeac9e6e9251c08a619855fed666e26dd539e3e594
parent3f567ae02da70f5634d728d2d089e04a4f2fad56 (diff)
downloadqpdf-234e323743a48c3818313c887d029233fd210a15.tar.zst
Use authenticated API call for github API for better rate limits
-rw-r--r--.github/workflows/main.yml2
-rwxr-xr-xbuild-scripts/download-external-libs23
-rwxr-xr-xbuild-scripts/prebuild9
3 files changed, 24 insertions, 10 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 0cde6e85..aec50b2c 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: 'Run pre-build steps'
- run: build-scripts/prebuild
+ run: build-scripts/prebuild ${{ secrets.GITHUB_TOKEN }}
- name: 'Upload documentation for later build steps'
uses: actions/upload-artifact@v3
with:
diff --git a/build-scripts/download-external-libs b/build-scripts/download-external-libs
index 5c437c23..79c9d348 100755
--- a/build-scripts/download-external-libs
+++ b/build-scripts/download-external-libs
@@ -30,16 +30,23 @@ src_name = 'qpdf-external-libs-src.zip'
dir_name = 'external-libs-dist'
os.makedirs(dir_name, exist_ok=True)
-r = requests.get(
- 'https://api.github.com/repos/qpdf/external-libs/releases')
-releases = json.loads(r.text)
+github_headers = {
+ 'content-type': 'application/json',
+}
+try:
+ token = sys.argv[1]
+ github_headers['authorization'] = f'Bearer {token}'
+except IndexError:
+ print('WARNING: unauthenticated call to github API'
+ ' will be subject to more stringent rate limits.')
-# Help diagnose occasional failure where some releases don't have
-# 'prerelease'. I've never seen this in attempts to reproduce.
-print("---- github API output for external-libs releaes ----")
-print(json.dumps(releases, indent=2, separators=(',', ': ')))
-print("--------")
+r = requests.get(
+ 'https://api.github.com/repos/qpdf/external-libs/releases',
+ headers=github_headers)
+if r.status_code >= 400:
+ exit(f'GitHub API call returned status {r.status_code}: {r.text}')
+releases = json.loads(r.text)
by_tag = sorted(
[(r['tag_name'], r) for r in releases
if r['prerelease'] is False],
diff --git a/build-scripts/prebuild b/build-scripts/prebuild
index 44b59949..00f48dd3 100755
--- a/build-scripts/prebuild
+++ b/build-scripts/prebuild
@@ -1,6 +1,13 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
+
+token=$1
+if [ "$token" = "" ]; then
+ echo 1>&2 "Usage: $0 github-token"
+ exit 2
+fi
+
if ! ./generate_auto_job --check; then
cat 1>&2 <<EOF
@@ -18,4 +25,4 @@ EOF
exit 2
fi
build-scripts/build-doc
-build-scripts/download-external-libs
+build-scripts/download-external-libs $token