Skip to content

Commit b471016

Browse files
committed
update pull_request.yml
1 parent 8172bab commit b471016

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.github/workflows/pull_requests.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,31 @@ jobs:
2020
- uses: actions/setup-go@v2
2121
with:
2222
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
2331
- name: terrafmt
2432
run: |
2533
export PATH=$PATH:$(go env GOPATH)/bin
2634
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
2848
2949
pre-pr-check:
3050
runs-on: ubuntu-latest
@@ -45,6 +65,8 @@ jobs:
4565
if [ -z "${{ github.event.number }}" ]; then
4666
CHANGED_FOLDERS=$(find ./quickstarts -maxdepth 1 -mindepth 1 -type d | tr '\n' ',')
4767
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
5072
sh scripts/terraform-validate.sh

0 commit comments

Comments
 (0)