diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 4a4403f8a..61a627826 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -29,3 +29,5 @@ jobs: cache: true - name: Run e2e run: make e2e + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/install_script.yml b/.github/workflows/install_script.yml index a76b3d945..81b240cb6 100644 --- a/.github/workflows/install_script.yml +++ b/.github/workflows/install_script.yml @@ -27,6 +27,8 @@ jobs: run: | ./install_linux.sh tflint -v + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install specific version env: TFLINT_VERSION: v0.15.0 @@ -40,6 +42,7 @@ jobs: "$TFLINT_INSTALL_PATH/tflint" -v env: TFLINT_INSTALL_PATH: ${{ github.workspace }}/install-path + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash container: runs-on: ubuntu-latest @@ -51,7 +54,7 @@ jobs: uses: actions/checkout@v3 - name: Install dependencies run: | - apk add bash curl unzip + apk add bash curl curl-dev unzip - name: Install latest version run: | ./install_linux.sh diff --git a/install_linux.sh b/install_linux.sh index ef33e0f07..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 --silent "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,20 +50,17 @@ 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} fi echo "Downloading TFLint $version" -curl --fail --silent -L -o "${download_zip}" "https://github.com/terraform-linters/tflint/releases/download/${version}/tflint_${os}.zip" -retVal=$? -if [ $retVal -ne 0 ]; then - echo "Failed to download tflint_${os}.zip" - exit $retVal -else - echo "Downloaded successfully" -fi +curl --fail -sS -L -o "${download_zip}" "https://github.com/terraform-linters/tflint/releases/download/${version}/tflint_${os}.zip" +echo "Downloaded successfully" echo -e "\n\n====================================================" echo "Unpacking ${download_zip} ..."