File tree 2 files changed +16
-27
lines changed
2 files changed +16
-27
lines changed Original file line number Diff line number Diff line change @@ -15,33 +15,22 @@ jobs:
15
15
terrafmt :
16
16
runs-on : ubuntu-latest
17
17
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
32
21
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
45
34
46
35
pre-pr-check :
47
36
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change 9
9
terraform -chdir=$f init -upgrade
10
10
terraform -chdir=$f validate
11
11
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."
13
13
exit 1
14
14
fi
15
15
done
You can’t perform that action at this time.
0 commit comments