File tree 1 file changed +60
-0
lines changed 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : ci
2
+
3
+ on :
4
+ pull_request :
5
+ branches :
6
+ - main
7
+
8
+ env :
9
+ DEFAULT_BRANCH : origin/main
10
+
11
+ jobs :
12
+ changes :
13
+ runs-on : ubuntu-latest
14
+
15
+ outputs :
16
+ modules : ${{ steps.get-changed-modules.outputs.modules}}
17
+
18
+ steps :
19
+ - name : Checkout repository
20
+ uses : actions/checkout@v3
21
+ with :
22
+ fetch-depth : 0
23
+
24
+ - name : Get branch name
25
+ id : branch-name
26
+ uses : tj-actions/branch-names@v7
27
+
28
+ - name : Get changed terraform modules
29
+ id : get-changed-modules
30
+ run : |
31
+ echo "modules=$(git diff --name-only \
32
+ origin/${{ steps.branch-name.outputs.current_branch }} \
33
+ ${{ env.DEFAULT_BRANCH }} | \
34
+ grep '.tf' | \
35
+ xargs dirname | \
36
+ sort -u | \
37
+ jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
38
+
39
+ validate-fmt-check :
40
+ needs : [changes]
41
+ if : ${{ needs.changes.outputs.modules != '[]' && needs.changes.outputs.modules != '' }}
42
+ runs-on : ubuntu-latest
43
+
44
+ strategy :
45
+ matrix :
46
+ module : ${{fromJson(needs.changes.outputs.modules)}}
47
+
48
+ steps :
49
+ - name : Checkout
50
+ uses : actions/checkout@v3
51
+
52
+ - name : terraform validate
53
+ uses : dflook/terraform-validate@v1
54
+ with :
55
+ path : " ${{ matrix.module }}"
56
+
57
+ - name : terraform fmt
58
+ uses : dflook/terraform-fmt-check@v1
59
+ with :
60
+ path : " ${{ matrix.module }}"
You can’t perform that action at this time.
0 commit comments