Skip to content

Commit a3d6f24

Browse files
authored
chore: switch to use setup-binary for terraform linter (#104)
Tested on GHES
1 parent d002584 commit a3d6f24

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

.github/actions/lint-terraform/action.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ inputs:
2323
description: 'The directory upon which to lint Terraform configurations.'
2424
type: 'string'
2525
required: true
26+
default: '.'
27+
terraform_linter_version:
28+
description: 'The version of the terraform linter to install and use.'
29+
type: 'string'
30+
required: true
31+
default: '0.2.0'
2632

2733
runs:
2834
using: 'composite'
@@ -39,8 +45,20 @@ runs:
3945
run: |-
4046
terraform fmt -recursive -check -diff
4147
42-
- name: 'abcxyz Terraform linter'
43-
if: 'always()'
44-
uses: 'abcxyz/terraform-linter@main' # ratchet:exclude
48+
- name: 'Setup terraform-linter'
49+
uses: 'abcxyz/actions/.github/actions/setup-binary@main' # ratchet:exclude
4550
with:
46-
paths: '${{ inputs.directory }}'
51+
download_url: 'https://github.com/abcxyz/terraform-linter/releases/download/v${{ inputs.terraform_linter_version }}/terraform-linter_linux_amd64'
52+
install_path: '${{ runner.temp }}/.terraform-linter'
53+
binary_subpath: 'terraform-linter_linux_amd64'
54+
cache_key: '${{ runner.os }}_${{ runner.arch }}_terraform_linter_${{ inputs.terraform_linter_version }}'
55+
add_to_path: true
56+
destination_subpath: 'terraform-linter'
57+
58+
- name: 'Run abcxyz/terraform-linter'
59+
shell: 'bash'
60+
env:
61+
LINT_PATHS: |-
62+
${{ inputs.directory || '.' }}
63+
run: |-
64+
terraform-linter lint ${LINT_PATHS}

.github/workflows/.lint-actions.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ jobs:
151151
##############
152152
TERRAFORM_LINT_TERRAFORM_VERSION: |-
153153
${{ vars.TERRAFORM_LINT_TERRAFORM_VERSION }}
154+
TERRAFORM_LINT_TERRAFORM_LINTER_VERSION: |-
155+
${{ vars.TERRAFORM_LINT_TERRAFORM_LINTER_VERSION || '0.2.0' }}
154156
TERRAFORM_LINT_DIRECTORY: |-
155157
${{ vars.TERRAFORM_LINT_DIRECTORY || '' }}
156158
##############
@@ -216,6 +218,7 @@ jobs:
216218
uses: './.github/actions/lint-terraform' # ratchet:exclude
217219
with:
218220
terraform_version: '${{ env.TERRAFORM_LINT_TERRAFORM_VERSION }}'
221+
terraform_linter_version: '${{ env.TERRAFORM_LINT_TERRAFORM_LINTER_VERSION }}'
219222
directory: '${{ env.TERRAFORM_LINT_DIRECTORY }}'
220223

221224
- name: '[YAML] lint yaml'

.github/workflows/lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ jobs:
152152
##############
153153
TERRAFORM_LINT_TERRAFORM_VERSION: |-
154154
${{ vars.TERRAFORM_LINT_TERRAFORM_VERSION }}
155+
TERRAFORM_LINT_TERRAFORM_LINTER_VERSION: |-
156+
${{ vars.TERRAFORM_LINT_TERRAFORM_LINTER_VERSION || '0.2.0' }}
155157
TERRAFORM_LINT_DIRECTORY: |-
156158
${{ vars.TERRAFORM_LINT_DIRECTORY || '' }}
157159
##############
@@ -223,6 +225,7 @@ jobs:
223225
uses: 'abcxyz/actions/.github/actions/lint-terraform@main' # ratchet:exclude
224226
with:
225227
terraform_version: '${{ env.TERRAFORM_LINT_TERRAFORM_VERSION }}'
228+
terraform_linter_version: '${{ env.TERRAFORM_LINT_TERRAFORM_LINTER_VERSION }}'
226229
directory: '${{ env.TERRAFORM_LINT_DIRECTORY }}'
227230

228231
- name: '[YAML] lint yaml'

0 commit comments

Comments
 (0)