Skip to content

Commit a5e715a

Browse files
authored
Configurable Terraform directory (#71)
1 parent c2baa05 commit a5e715a

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/terraform.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
skip_validate:
1010
type: boolean
1111
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: "."
1216

1317
env:
1418
# OpsGenie Terraform provider needs this to be non-empty, even if we only validate the code.
@@ -25,6 +29,10 @@ jobs:
2529
- name: Setup terraform
2630
uses: hashicorp/setup-terraform@v3
2731

32+
- name: Change working directory
33+
run: cd ${{ inputs.terraform_directory }}
34+
if: ${{ inputs.terraform_directory != '.' }}
35+
2836
- name: Terraform fmt
2937
id: fmt
3038
run: terraform fmt -check -recursive -diff
@@ -69,13 +77,13 @@ jobs:
6977
with:
7078
source-repo: riege/code-quality
7179
source-path: terraform/.tflint.hcl
72-
destination-path: ${{ github.workspace }}/.tflint.hcl
80+
destination-path: ${{ github.workspace }}/${{ inputs.terraform_directory }}/.tflint.hcl
7381
token: ${{ github.token }}
7482

7583
- name: Determine TFLint config file location
7684
if: success() || failure()
7785
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"
7987
8088
- name: Cache plugin dir
8189
uses: actions/cache@v4
@@ -112,12 +120,12 @@ jobs:
112120
- name: Run TFLint (PR)
113121
if: ${{ github.event_name == 'pull_request' && (success() || failure()) }}
114122
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
116124
117125
- name: Report Result
118126
uses: jwgmeligmeyling/checkstyle-github-action@master
119127
if: ${{ github.event_name == 'pull_request' && (success() || failure()) }}
120128
with:
121129
title: TFLint Report
122130
name: TFLint Report
123-
path: tflint-report.xml
131+
path: ${{ github.workspace }}/tflint-report.xml

0 commit comments

Comments
 (0)