File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Pull Request Checks
2
+
3
+ on :
4
+ pull_request :
5
+ branches :
6
+ - master
7
+ - main
8
+ types : [ 'opened', 'synchronize' ]
9
+ paths :
10
+ - ' .github/**'
11
+ - ' .github/workflows/**'
12
+ - ' quickstarts/**'
13
+
14
+ jobs :
15
+ terrafmt :
16
+ runs-on : ubuntu-latest
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 : terrafmt
24
+ run : |
25
+ export PATH=$PATH:$(go env GOPATH)/bin
26
+ go install github.com/katbyte/terrafmt@latest
27
+ terrafmt diff ./quickstarts --check --pattern '*.tf'
28
+
29
+ prepr-check :
30
+ runs-on : ubuntu-latest
31
+ steps :
32
+ - name : checkout
33
+ uses : actions/checkout@v3
34
+ - name : Get changed files
35
+ id : changed-files
36
+ uses : tj-actions/changed-files@v34
37
+ with :
38
+ dir_names : " true"
39
+ separator : " ,"
40
+ files : " quickstart/*"
41
+ dir_names_max_depth : 2
42
+ - name : pr-check
43
+ run : |
44
+ export CHANGED_FOLDERS="${{ steps.changed-files.outputs.all_changed_files }}"
45
+ if [ -z "${{ github.event.number }}" ]; then
46
+ CHANGED_FOLDERS=$(find ./quickstarts -maxdepth 1 -mindepth 1 -type d | tr '\n' ',')
47
+ 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/
50
+ sh scripts/terraform-validate.sh
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ error=false
3
+
4
+ folders=$CHANGED_FOLDERS
5
+ for f in ${folders// ,/ }
6
+ do
7
+ f=$( echo $f | xargs echo -n)
8
+ (echo " ===> Terraform validating in" /src/$f && cd /src/$f && rm -f .terraform.lock.hcl && rm -rf .terraform && terraform init -upgrade && terraform validate -json | jq -e .valid) || error=true
9
+ if ${error} ; then
10
+ echo " ------------------------------------------------"
11
+ echo " "
12
+ echo " Some Terraform codes contain errors."
13
+ echo " $( cd /src/$f && terraform validate -json) "
14
+ echo " "
15
+ exit 1
16
+ fi
17
+ done
18
+
19
+ exit 0
You can’t perform that action at this time.
0 commit comments