gh/scripts/download-gh-asset.sh: use $GITHUB_TOKEN

Use $GITHUB_TOKEN if provided (it is in the CI) to get around API rate
limiting (it already is used by the curl calls made by fetch_json
function).
This commit is contained in:
Martin Pulec
2024-10-08 16:55:06 +02:00
parent 6475aa7358
commit 94abcab830

View File

@@ -21,5 +21,10 @@ gh_path_json=$(fetch_json "$gh_release" "${GITHUB_TOKEN-}" array)
gh_path=$(jq -r '[.[] | select(.name | test(".*'"$pattern"'.*"))] |
.[0].browser_download_url' "$gh_path_json")
rm -- "$gh_path_json"
curl -sSL "$gh_path" -o "$file"
if [ -n "${GITHUB_TOKEN-}" ]; then
set -- -H "Authorization: token $GITHUB_TOKEN"
else
set --
fi
curl -sSL "$@" "$gh_path" -o "$file"