From fcc9cd64070679c9241b678ad35be8c15288218d Mon Sep 17 00:00:00 2001 From: Kazuma Watanabe Date: Sun, 25 Dec 2022 09:04:15 +0000 Subject: [PATCH] Allow passing GITHUB_TOKEN to install script --- install_linux.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/install_linux.sh b/install_linux.sh index 0ce660b76..372024eae 100755 --- a/install_linux.sh +++ b/install_linux.sh @@ -35,9 +35,13 @@ echo "os=$os" echo -e "\n\n====================================================" get_latest_release() { - curl --fail -sS "https://api.github.com/repos/terraform-linters/tflint/releases/latest" | # Get latest release from GitHub api - grep '"tag_name":' | # Get tag line - sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value + headers=() + if [ -n "${GITHUB_TOKEN}" ]; then + headers=(-H "Authorization: Bearer ${GITHUB_TOKEN}") + fi + curl --fail -sS "${headers[@]}" "https://api.github.com/repos/terraform-linters/tflint/releases/latest" | # Get latest release from GitHub api + grep '"tag_name":' | # Get tag line + sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value } download_path=$(mktemp -d -t tflint.XXXXXXXXXX) @@ -46,6 +50,9 @@ download_executable="${download_path}/tflint" if [ -z "${TFLINT_VERSION}" ] || [ "${TFLINT_VERSION}" == "latest" ]; then echo "Looking up the latest version ..." + if [ -n "${GITHUB_TOKEN}" ]; then + echo "Requesting with GITHUB_TOKEN ..." + fi version=$(get_latest_release) else version=${TFLINT_VERSION}