File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -20,11 +20,31 @@ jobs:
20
20
- uses : actions/setup-go@v2
21
21
with :
22
22
go-version : ${{ env.GO_VERSION }}
23
+ - name : Get changed files
24
+ id : changed-files
25
+ uses : tj-actions/changed-files@v34
26
+ with :
27
+ dir_names : " true"
28
+ separator : " ,"
29
+ files : " quickstarts/*"
30
+ dir_names_max_depth : 2
23
31
- name : terrafmt
24
32
run : |
25
33
export PATH=$PATH:$(go env GOPATH)/bin
26
34
go install github.com/katbyte/terrafmt@latest
27
- terrafmt diff ./quickstarts --check --pattern '*.tf'
35
+ folders=${{ steps.changed-files.outputs.all_changed_files }}
36
+ for f in ${folders//,/ }
37
+ do
38
+ f=$(echo $f | xargs echo -n)
39
+ (echo "===> Terraform fmt checking in" $f && terrafmt diff $f --check) || error=true
40
+ if ${error}; then
41
+ echo "------------------------------------------------"
42
+ echo ""
43
+ echo "Some Terraform codes has not formated, and please running terraform fmt --recursive before pushing"
44
+ echo ""
45
+ exit 1
46
+ fi
47
+ done
28
48
29
49
pre-pr-check :
30
50
runs-on : ubuntu-latest
45
65
if [ -z "${{ github.event.number }}" ]; then
46
66
CHANGED_FOLDERS=$(find ./quickstarts -maxdepth 1 -mindepth 1 -type d | tr '\n' ',')
47
67
fi
48
- wget https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
49
- unzip terraform_1.6.0_linux_amd64.zip -d /usr/local/bin/
68
+ if [ -f /usr/local/bin/terraform ]; then
69
+ wget https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
70
+ unzip terraform_1.6.0_linux_amd64.zip -d /usr/local/bin/
71
+ fi
50
72
sh scripts/terraform-validate.sh
You can’t perform that action at this time.
0 commit comments