Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow specifying the CPU architecture to support ARM based runners #23

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pre-commit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 13 additions & 8 deletions pre-commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down