-
-
Notifications
You must be signed in to change notification settings - Fork 21
66 lines (62 loc) · 1.91 KB
/
pipeline.yml
File metadata and controls
66 lines (62 loc) · 1.91 KB
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
60
61
62
63
64
65
66
name: Terraform
on:
push:
branches: [main]
pull_request:
types: [opened, reopened, synchronize]
branches: [main]
release:
types: [published]
env:
DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: localstack
AWS_SECRET_ACCESS_KEY: localstack
jobs:
check-format:
runs-on: ubuntu-latest
container: hashicorp/terraform
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Terraform Format Check
run: terraform fmt -check -recursive -diff
discover-examples:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set validation matrix
id: set-matrix
run: |
# Find all subdirectories in examples folder and convert to JSON array
DIRS=$(find examples -maxdepth 1 -mindepth 1 -type d | sort)
MATRIX=$(echo "$DIRS" | jq -R . | jq -s . | tr -d '\n')
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
validations:
needs: discover-examples
runs-on: ubuntu-latest
container: hashicorp/terraform
strategy:
matrix:
dir: ${{ fromJson(needs.discover-examples.outputs.matrix) }}
services:
localstack:
image: localstack/localstack
env:
SERVICES: apigateway,cloudformation,cloudwatch,dynamodb,es,firehose,iam,kinesis,lambda,route53,redshift,s3,secretsmanager,ses,sns,sqs,ssm,stepfunctions,sts
ports:
- 4566:4566
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Terraform Init
run: terraform init -upgrade
working-directory: ${{ matrix.dir }}
- name: Terraform Validate
run: terraform validate
working-directory: ${{ matrix.dir }}
- name: Terraform Plan (Mock)
run: terraform plan
working-directory: ${{ matrix.dir }}