|
| 1 | +name: Automatic CI for TFE Modules |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +defaults: |
| 9 | + run: |
| 10 | + shell: bash |
| 11 | + |
| 12 | +jobs: |
| 13 | + terraform_format: |
| 14 | + |
| 15 | + name: Run terraform fmt |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v2 |
| 22 | + with: |
| 23 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + persist-credentials: false |
| 25 | + |
| 26 | + - name: Setup Terraform |
| 27 | + uses: hashicorp/setup-terraform@v1 |
| 28 | + with: |
| 29 | + terraform_version: 1.0.11 |
| 30 | + |
| 31 | + - name: Format all .tf files recursively |
| 32 | + run: | |
| 33 | + terraform fmt -check -diff -recursive ${{ github.workspace }} |
| 34 | + terraform_lint: |
| 35 | + |
| 36 | + name: Run terraform-lint |
| 37 | + runs-on: ubuntu-latest |
| 38 | + permissions: |
| 39 | + contents: read |
| 40 | + |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v2 |
| 43 | + with: |
| 44 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + persist-credentials: false |
| 46 | + |
| 47 | + - name: Setup Terraform Lint |
| 48 | + uses: terraform-linters/setup-tflint@v1 |
| 49 | + with: |
| 50 | + tflint_version: v0.34.1 |
| 51 | + |
| 52 | + - name: Terraform Init |
| 53 | + id: init |
| 54 | + run: | |
| 55 | + terraform init |
| 56 | +
|
| 57 | + - name: Lint root module |
| 58 | + run: | |
| 59 | + tflint --config ${{ github.workspace }}/.tflint.hcl ${{ github.workspace }} |
| 60 | + - name: Lint collector-dashboards directory in a loop |
| 61 | + run: | |
| 62 | + for m in $(ls -1d collector-dashboards/*/) |
| 63 | + do |
| 64 | + tflint \ |
| 65 | + --config ${{ github.workspace }}/.tflint.hcl \ |
| 66 | + ${{ github.workspace }}/${m} |
| 67 | + done |
| 68 | + - name: Lint examples directory in a loop |
| 69 | + run: | |
| 70 | + for m in $(ls -1d examples/*/) |
| 71 | + do |
| 72 | + tflint \ |
| 73 | + --config ${{ github.workspace }}/.tflint.hcl \ |
| 74 | + ${{ github.workspace }}/${m} |
| 75 | + done |
0 commit comments