|
1 |
| -name: Pre-Commit |
| 1 | +name: TF Pre-Commit |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
2 | 5 |
|
3 | 6 | on:
|
4 | 7 | pull_request:
|
5 | 8 | branches:
|
6 | 9 | - main
|
7 | 10 | - master
|
8 | 11 |
|
9 |
| -env: |
10 |
| - TERRAFORM_DOCS_VERSION: v0.16.0 |
11 |
| - |
12 | 12 | jobs:
|
13 |
| - collectInputs: |
14 |
| - name: Collect workflow inputs |
15 |
| - runs-on: ubuntu-latest |
16 |
| - outputs: |
17 |
| - directories: ${{ steps.dirs.outputs.directories }} |
18 |
| - steps: |
19 |
| - - name: Checkout |
20 |
| - uses: actions/checkout@v2 |
21 |
| - |
22 |
| - - name: Get root directories |
23 |
| - id: dirs |
24 |
| - uses: clowdhaus/terraform-composite-actions/[email protected] |
25 |
| - |
26 |
| - preCommitMinVersions: |
27 |
| - name: Min TF pre-commit |
28 |
| - needs: collectInputs |
29 |
| - runs-on: ubuntu-latest |
30 |
| - strategy: |
31 |
| - matrix: |
32 |
| - directory: ${{ fromJson(needs.collectInputs.outputs.directories) }} |
33 |
| - steps: |
34 |
| - - name: Checkout |
35 |
| - uses: actions/checkout@v2 |
36 |
| - |
37 |
| - - name: Terraform min/max versions |
38 |
| - id: minMax |
39 |
| - |
40 |
| - with: |
41 |
| - directory: ${{ matrix.directory }} |
42 |
| - |
43 |
| - - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} |
44 |
| - # Run only validate pre-commit check on min version supported |
45 |
| - if: ${{ matrix.directory != '.' }} |
46 |
| - uses: clowdhaus/terraform-composite-actions/[email protected] |
47 |
| - with: |
48 |
| - terraform-version: ${{ steps.minMax.outputs.minVersion }} |
49 |
| - args: "terraform-validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*" |
50 |
| - |
51 |
| - - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} |
52 |
| - # Run only validate pre-commit check on min version supported |
53 |
| - if: ${{ matrix.directory == '.' }} |
54 |
| - uses: clowdhaus/terraform-composite-actions/[email protected] |
55 |
| - with: |
56 |
| - terraform-version: ${{ steps.minMax.outputs.minVersion }} |
57 |
| - args: "terraform-validate --color=always --show-diff-on-failure --files $(ls *.tf)" |
58 |
| - |
59 |
| - preCommitMaxVersion: |
60 |
| - name: Max TF pre-commit |
61 |
| - runs-on: ubuntu-latest |
62 |
| - needs: collectInputs |
63 |
| - steps: |
64 |
| - - name: Checkout |
65 |
| - uses: actions/checkout@v2 |
66 |
| - with: |
67 |
| - ref: ${{ github.event.pull_request.head.ref }} |
68 |
| - repository: ${{github.event.pull_request.head.repo.full_name}} |
69 |
| - |
70 |
| - - name: Terraform min/max versions |
71 |
| - id: minMax |
72 |
| - |
73 |
| - |
74 |
| - # Step required as tflint pre-commit hook requires module to be initialised |
75 |
| - - run: terraform init |
76 |
| - |
77 |
| - - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} |
78 |
| - uses: clowdhaus/terraform-composite-actions/[email protected] |
79 |
| - with: |
80 |
| - terraform-version: ${{ steps.minMax.outputs.maxVersion }} |
81 |
| - terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }} |
82 |
| - # tflint-version: ${{ env.TFLINT_VERSION }} # use this version with "Invicton-Labs/deepmerge/null" module |
| 13 | + main: |
| 14 | + uses: getindata/github-workflows/.github/workflows/tf-pre-commit.yml@v1 |
| 15 | + with: |
| 16 | + # tflint v0.46.0 is the latest version we can use with pre-commit v0.1.20 |
| 17 | + # See .pre-commit-config.yaml for more details. |
| 18 | + tflint-version: v0.46.0 |
0 commit comments