diff --git a/build-branches.sh b/build-branches.sh index 36c55d7..3bd93a9 100755 --- a/build-branches.sh +++ b/build-branches.sh @@ -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" diff --git a/build-latest.sh b/build-latest.sh index e996251..d903f8f 100755 --- a/build-latest.sh +++ b/build-latest.sh @@ -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"