diff --git a/README.md b/README.md index 298c5bc..fa20827 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ jobs: # Configure default software terraform-version: 1.2.0 terraform-docs-version: v0.16.0 + terraform-architecture: amd64 # Configure optional software install-hcledit: true hcledit-version: 0.2.3 diff --git a/pre-commit/README.md b/pre-commit/README.md index bff96e6..1e80cf5 100644 --- a/pre-commit/README.md +++ b/pre-commit/README.md @@ -27,6 +27,7 @@ jobs: with: terraform-version: 1.2.0 terraform-docs-version: v16.0.0 + terraform-architecture: amd64 install-hcledit: true hcledit-version: 0.2.3 args: "--all-files --color always --show-diff-on-failure" diff --git a/pre-commit/action.yml b/pre-commit/action.yml index 2b94c98..a89ee3e 100644 --- a/pre-commit/action.yml +++ b/pre-commit/action.yml @@ -8,6 +8,10 @@ inputs: description: Version of terraform-docs to use when evaluating checks required: false default: v0.16.0 + terraform-architecture: + description: Terraform architecture to use when evaluating checks + required: false + default: amd64 tflint-version: description: Version of tflint to use when evaluating checks required: false @@ -40,35 +44,36 @@ runs: shell: bash run: | rm -rf $(which terraform) - curl --retry 3 --retry-all-errors --retry-delay 3 -sSO https://releases.hashicorp.com/terraform/${{ inputs.terraform-version }}/terraform_${{ inputs.terraform-version }}_linux_amd64.zip - sudo unzip -qq terraform_${{ inputs.terraform-version }}_linux_amd64.zip terraform -d /usr/bin/ - rm terraform_${{ inputs.terraform-version }}_linux_amd64.zip 2> /dev/null + curl --retry 3 --retry-all-errors --retry-delay 3 -sSO https://releases.hashicorp.com/terraform/${{ inputs.terraform-version }}/terraform_${{ inputs.terraform-version }}_linux_${{ inputs.terraform-architecture }}.zip + sudo unzip -qq terraform_${{ inputs.terraform-version }}_linux_${{ inputs.terraform-architecture }}.zip terraform -d /usr/bin/ + rm terraform_${{ inputs.terraform-version }}_linux_${{ inputs.terraform-architecture }}.zip 2> /dev/null - name: Install pre-commit dependencies shell: bash run: | pip install -q pre-commit - curl --retry 3 --retry-all-errors --retry-delay 3 -sSLo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/${{ inputs.terraform-docs-version }}/terraform-docs-${{ inputs.terraform-docs-version }}-$(uname)-amd64.tar.gz + curl --retry 3 --retry-all-errors --retry-delay 3 -sSLo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/${{ inputs.terraform-docs-version }}/terraform-docs-${{ inputs.terraform-docs-version }}-$(uname)-${{ inputs.terraform-architecture }}.tar.gz sudo tar -xzf terraform-docs.tar.gz -C /usr/bin/ terraform-docs rm terraform-docs.tar.gz 2> /dev/null + rm -rf $(which tflint) if [[ "${{ inputs.tflint-version }}" == "latest" ]]; then - curl --retry 3 --retry-all-errors --retry-delay 3 -sSL "$(curl --retry 3 --retry-all-errors --retry-delay 3 -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip + curl --retry 3 --retry-all-errors --retry-delay 3 -sSL "$(curl --retry 3 --retry-all-errors --retry-delay 3 -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_${{ inputs.terraform-architecture }}.zip")" > tflint.zip else - curl --retry 3 --retry-all-errors --retry-delay 3 -sSLo ./tflint.zip https://github.com/terraform-linters/tflint/releases/download/${{ inputs.tflint-version }}/tflint_linux_amd64.zip + curl --retry 3 --retry-all-errors --retry-delay 3 -sSLo ./tflint.zip https://github.com/terraform-linters/tflint/releases/download/${{ inputs.tflint-version }}/tflint_linux_${{ inputs.terraform-architecture }}.zip fi sudo unzip -qq tflint.zip tflint -d /usr/bin/ rm tflint.zip 2> /dev/null if [[ "${{ inputs.install-hcledit }}" == "true" ]]; then - curl --retry 3 --retry-all-errors --retry-delay 3 -sSLo ./hcledit.tar.gz https://github.com/minamijoyo/hcledit/releases/download/v${{ inputs.hcledit-version }}/hcledit_${{ inputs.hcledit-version }}_$(uname)_amd64.tar.gz + curl --retry 3 --retry-all-errors --retry-delay 3 -sSLo ./hcledit.tar.gz https://github.com/minamijoyo/hcledit/releases/download/v${{ inputs.hcledit-version }}/hcledit_${{ inputs.hcledit-version }}_$(uname)_${{ inputs.terraform-architecture }}.tar.gz sudo tar -xzf hcledit.tar.gz -C /usr/bin/ hcledit rm hcledit.tar.gz 2> /dev/null fi if [[ "${{ inputs.install-tfsec }}" == "true" ]]; then - curl --retry 3 --retry-all-errors --retry-delay 3 -sSLo ./tfsec.tar.gz https://github.com/aquasecurity/tfsec/releases/download/v${{ inputs.tfsec-version }}/tfsec_${{ inputs.tfsec-version }}_$(uname)_amd64.tar.gz + curl --retry 3 --retry-all-errors --retry-delay 3 -sSLo ./tfsec.tar.gz https://github.com/aquasecurity/tfsec/releases/download/v${{ inputs.tfsec-version }}/tfsec_${{ inputs.tfsec-version }}_$(uname)_${{ inputs.terraform-architecture }}.tar.gz sudo tar -xzf tfsec.tar.gz -C /usr/bin/ tfsec tfsec-checkgen rm tfsec.tar.gz 2> /dev/null fi