diff --git a/scripts/get-helm-3 b/scripts/get-helm-3 index b5e53bafc..5eab952a0 100755 --- a/scripts/get-helm-3 +++ b/scripts/get-helm-3 @@ -111,11 +111,19 @@ checkDesiredVersion() { local latest_release_url="https://api.github.com/repos/helm/helm/releases/latest" local latest_release_response="" if [ "${HAS_CURL}" == "true" ]; then - latest_release_response=$( curl -L --silent --show-error --fail "$latest_release_url" 2>&1 || true ) + if [ "${GITHUB_TOKEN}" != ""]; then + latest_release_response=$( curl --header "Authorization: Bearer ${GITHUB_TOKEN}" -L --silent --show-error --fail "$latest_release_url" 2>&1 || true ) + else + latest_release_response=$( curl -L --silent --show-error --fail "$latest_release_url" 2>&1 || true ) + fi elif [ "${HAS_WGET}" == "true" ]; then - latest_release_response=$( wget "$latest_release_url" -O - 2>&1 || true ) + if [ "${GITHUB_TOKEN}" != ""]; then + latest_release_response=$( wget --header="Authorization: Bearer ${GITHUB_TOKEN}" "$latest_release_url" -O - 2>&1 || true ) + else + latest_release_response=$( wget "$latest_release_url" -O - 2>&1 || true ) + fi fi - TAG=$( echo "$latest_release_response" | grep '"tag_name"' | sed -E 's/.*"(v[0-9\.]+)".*/\1/g' ) + TAG=$( echo "$latest_release_response" | grep -o '"tag_name":[[:space]]*".*"' | cut -d '"' -f 4 ) if [ "x$TAG" == "x" ]; then printf "Could not retrieve the latest release tag information from %s: %s\n" "${latest_release_url}" "${latest_release_response}" exit 1