-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (53 loc) · 1.93 KB
/
terraform-min-max.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Terraform min-max
on:
pull_request:
jobs:
collectDirectories:
name: 🍱 collect directories
# Outputs a list of all unique directories
# that contain *.tf files and do not start with .
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: set-matrix
run: |
DIRS=$(find . -type f -name '*.tf' -not -path '**/.*' | sed -r 's|/[^/]+$||' | sort | uniq)
DIRS_JSON=$(jq -ncR '[inputs]' <<< "$DIRS")
cat <<< matrix=$DIRS_JSON >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
validateTerraformMinMaxVersions:
name: 🏗️ Validate Terraform min/max versions
needs: collectDirectories
# For public repos use runs-on: ubuntu-latest
# For private repos use runs-on: self-hosted
runs-on: ubuntu-latest
container: bjorncloudandthings/terraform-aws-github:latest
strategy:
matrix:
directory: ${{ fromJson(needs.collectDirectories.outputs.directories) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get Terraform min/max versions
id: minMax
uses: clowdhaus/[email protected]
with:
directory: ${{ matrix.directory }}
- name: Validate min Terraform version (${{ steps.minMax.outputs.minVersion }})
run: |
ls -la ~
tfenv install ${{ steps.minMax.outputs.minVersion }}
tfenv use ${{ steps.minMax.outputs.minVersion }}
terraform --version
terraform init -backend=false
terraform validate
- name: Validate max Terraform version (${{ steps.minMax.outputs.maxVersion }})
run: |
ls -la ~
tfenv install ${{ steps.minMax.outputs.maxVersion }}
tfenv use ${{ steps.minMax.outputs.maxVersion }}
terraform --version
terraform init -backend=false
terraform validate