-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
action.yml
78 lines (71 loc) · 3.56 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: pre-commit
description: Execute pre-commit for Terraform codebase
inputs:
terraform-version:
description: Terraform version supported for use in evaluation
required: true
terraform-docs-version:
description: Version of terraform-docs to use when evaluating checks
required: false
default: v0.16.0
tflint-version:
description: Version of tflint to use when evaluating checks
required: false
default: latest
args:
description: Arguments to pass to pre-commit
required: false
default: '--all-files --color always --show-diff-on-failure'
install-hcledit:
description: Install hcledit for pre-commit
required: false
default: 'false'
hcledit-version:
description: Version of hcledit to install when `install-hcledit` is true
required: false
default: 0.2.10
install-tfsec:
description: Install tfsec for pre-commit
required: false
default: 'false'
tfsec-version:
description: Version of tfsec to install when `install-tfsec` is true
required: false
default: 1.28.5
runs:
using: composite
steps:
- name: Install Terraform v${{ inputs.terraform-version }}
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
- 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
sudo tar -xzf terraform-docs.tar.gz -C /usr/bin/ terraform-docs
rm terraform-docs.tar.gz 2> /dev/null
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
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
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
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
sudo tar -xzf tfsec.tar.gz -C /usr/bin/ tfsec tfsec-checkgen
rm tfsec.tar.gz 2> /dev/null
fi
- name: Execute pre-commit
shell: bash
run: pre-commit run ${{ inputs.args }}