File tree Expand file tree Collapse file tree 2 files changed +16
-27
lines changed Expand file tree Collapse file tree 2 files changed +16
-27
lines changed Original file line number Diff line number Diff line change @@ -15,33 +15,22 @@ jobs:
1515 terrafmt :
1616 runs-on : ubuntu-latest
1717 steps :
18- - uses : actions/checkout@v2
19- - run : echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
20- - uses : actions/setup-go@v2
21- with :
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
31- - name : terrafmt
18+ - name : checkout
19+ uses : actions/checkout@v3
20+ - name : terrafmt-check
3221 run : |
33- export PATH=$PATH:$(go env GOPATH)/ bin
34- go install github. com/katbyte/terrafmt@latest
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 "===> Terrafmt diff checking in" $f && terrafmt diff $f --check ) || error=true
40- if ${error}; then
41- echo -e "\033[1m[ERROR]\033[0m: Some quickstarts codes has not been formated, and please running terraform fmt --recursive command before pushing."
42- exit 1
43- fi
44- done
22+ if [ ! -f /usr/local/ bin/terraform ]; then
23+ wget -q https://releases.hashicorp. com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
24+ unzip terraform_1.6.0_linux_amd64.zip -d /usr/local/bin/
25+ fi
26+ error=false
27+ echo "===> Terraform fmt -diff checking in quickstarts"
28+ (terraform -chdir=quickstarts fmt -check -recursive -list=false ) || error=true
29+ terraform -chdir=quickstarts fmt -diff -recursive
30+ if ${error}; then
31+ echo -e "\031[1m[ERROR]\031[0m: Some quickstarts codes has not been formatted, and please running terraform fmt --recursive command before pushing."
32+ exit 1
33+ fi
4534
4635 pre-pr-check :
4736 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change 99 terraform -chdir=$f init -upgrade
1010 terraform -chdir=$f validate
1111 if [[ $? -ne 0 ]]; then
12- echo -e " \033 [1m[ERROR]\033 [0m: Some quickstarts codes contain errors, and please running terraform validate command before pushing."
12+ echo -e " \031 [1m[ERROR]\031 [0m: Some quickstarts codes contain errors, and please running terraform validate command before pushing."
1313 exit 1
1414 fi
1515done
You can’t perform that action at this time.
0 commit comments