mirror of
https://github.com/netbox-community/netbox-docker.git
synced 2024-11-27 02:14:14 +01:00
968bb9f10f
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
29 lines
922 B
Bash
Executable File
29 lines
922 B
Bash
Executable File
#!/bin/bash
|
|
# Builds develop, develop-* and master branches
|
|
|
|
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?${GITHUB_OAUTH_PARAMS}"
|
|
|
|
CURL="curl -sS"
|
|
|
|
BRANCHES=$($CURL "${URL_RELEASES}" | jq -r 'map(.name) | .[] | scan("^[^v].+") | match("^(master|develop).*") | .string')
|
|
|
|
ERROR=0
|
|
|
|
for BRANCH in $BRANCHES; do
|
|
# shellcheck disable=SC2068
|
|
./build.sh "${BRANCH}" $@ || ERROR=1
|
|
done
|
|
exit $ERROR
|