✨ Prevent Github API Rate Limits
When building netbox-docker on Travis, it happened too often that the build failed because of Github's API rate limits. These apply for all requests, but if the request is unauthenticated they are applied by IP. This is bad for netbox-docker, as we build on Travis where the build- workers are shared with the rest of the world. This commit adds the possibility to define OAuth credentials as documented at [1]. Hopefully this leads to more reliable releases of netbox-docker images. [1] https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
This commit is contained in:
parent
aafa6483dc
commit
968bb9f10f
@ -3,9 +3,17 @@
|
||||
|
||||
echo "▶️ $0 $*"
|
||||
|
||||
if [ ! -z "${GITHUB_OAUTH_CLIENT_ID}" ] && [ ! -z "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
|
||||
echo "🗝 Performing authenticated Github API calls."
|
||||
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
|
||||
else
|
||||
echo "🕶 Performing unauthenticated Github API calls. This might result in lower Github rate limits!"
|
||||
GITHUB_OAUTH_PARAMS=""
|
||||
fi
|
||||
|
||||
ORIGINAL_GITHUB_REPO="digitalocean/netbox"
|
||||
GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}"
|
||||
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/branches"
|
||||
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/branches?${GITHUB_OAUTH_PARAMS}"
|
||||
|
||||
CURL="curl -sS"
|
||||
|
||||
|
@ -3,9 +3,17 @@
|
||||
|
||||
echo "▶️ $0 $*"
|
||||
|
||||
if [ ! -z "${GITHUB_OAUTH_CLIENT_ID}" ] && [ ! -z "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
|
||||
echo "🗝 Performing authenticated Github API calls."
|
||||
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
|
||||
else
|
||||
echo "🕶 Performing unauthenticated Github API calls. This might result in lower Github rate limits!"
|
||||
GITHUB_OAUTH_PARAMS=""
|
||||
fi
|
||||
|
||||
ORIGINAL_GITHUB_REPO="digitalocean/netbox"
|
||||
GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}"
|
||||
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/releases"
|
||||
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/releases?${GITHUB_OAUTH_PARAMS}"
|
||||
|
||||
JQ_LATEST="group_by(.prerelease) | .[] | sort_by(.published_at) | reverse | .[0] | select(.prerelease==${PRERELEASE-false}) | .tag_name"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user