|
9 | 9 | skip_validate: |
10 | 10 | type: boolean |
11 | 11 | description: "Set to 'true' if Terraform validation shall be skipped. Might be necessary in some rare cases." |
| 12 | + terraform_directory: |
| 13 | + type: string |
| 14 | + description: "Path to the Terraform directory. Defaults to the root of the repository." |
| 15 | + default: "." |
12 | 16 |
|
13 | 17 | env: |
14 | 18 | # OpsGenie Terraform provider needs this to be non-empty, even if we only validate the code. |
|
25 | 29 | - name: Setup terraform |
26 | 30 | uses: hashicorp/setup-terraform@v3 |
27 | 31 |
|
| 32 | + - name: Change working directory |
| 33 | + run: cd ${{ inputs.terraform_directory }} |
| 34 | + if: ${{ inputs.terraform_directory != '.' }} |
| 35 | + |
28 | 36 | - name: Terraform fmt |
29 | 37 | id: fmt |
30 | 38 | run: terraform fmt -check -recursive -diff |
@@ -69,13 +77,13 @@ jobs: |
69 | 77 | with: |
70 | 78 | source-repo: riege/code-quality |
71 | 79 | source-path: terraform/.tflint.hcl |
72 | | - destination-path: ${{ github.workspace }}/.tflint.hcl |
| 80 | + destination-path: ${{ github.workspace }}/${{ inputs.terraform_directory }}/.tflint.hcl |
73 | 81 | token: ${{ github.token }} |
74 | 82 |
|
75 | 83 | - name: Determine TFLint config file location |
76 | 84 | if: success() || failure() |
77 | 85 | run: | |
78 | | - echo "TFLINT_CONFIG_FILE=${{ github.workspace }}/.tflint.hcl" >> "$GITHUB_ENV" |
| 86 | + echo "TFLINT_CONFIG_FILE=${{ github.workspace }}/${{ inputs.terraform_directory }}/.tflint.hcl" >> "$GITHUB_ENV" |
79 | 87 |
|
80 | 88 | - name: Cache plugin dir |
81 | 89 | uses: actions/cache@v4 |
@@ -112,12 +120,12 @@ jobs: |
112 | 120 | - name: Run TFLint (PR) |
113 | 121 | if: ${{ github.event_name == 'pull_request' && (success() || failure()) }} |
114 | 122 | run: | |
115 | | - tflint --format=checkstyle --recursive --config="$TFLINT_CONFIG_FILE" > tflint-report.xml |
| 123 | + tflint --format=checkstyle --recursive --config="$TFLINT_CONFIG_FILE" > ${{ github.workspace }}/tflint-report.xml |
116 | 124 |
|
117 | 125 | - name: Report Result |
118 | 126 | uses: jwgmeligmeyling/checkstyle-github-action@master |
119 | 127 | if: ${{ github.event_name == 'pull_request' && (success() || failure()) }} |
120 | 128 | with: |
121 | 129 | title: TFLint Report |
122 | 130 | name: TFLint Report |
123 | | - path: tflint-report.xml |
| 131 | + path: ${{ github.workspace }}/tflint-report.xml |
0 commit comments