-
Notifications
You must be signed in to change notification settings - Fork 1.4k
59 lines (48 loc) · 1.46 KB
/
terraform.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: "ashley gitops IAC"
on:
push:
branches:
- main
- stage
paths:
- terraform/** # Adjust the path filter if you have specific files like *.tf
pull_request:
branches:
- main
paths:
- terraform/** # Adjust the path filter if you have specific files like *.tf
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }}
AWS_REGION: us-east-1
EKS_CLUSTER: gitops-eks
jobs:
terraform:
name: "Apply Terraform changes"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./terraform
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Terraform with specified version on the runner
uses: hashicorp/setup-terraform@v2
- name: Terraform init
id: init
run: terraform init -backend-config="bucket=$BUCKET_TF_STATE"
- name: Terraform format
id: fmt
run: terraform fmt -check
- name: Terraform validate
id: validate
run: terraform validate
- name: Terraform plan
id: plan
run: terraform plan -no-color -input=false -out planfile
continue-on-error: true # Optional, remove if you don't want to continue on failure
- name: Terraform plan status
if: steps.plan.outcome == 'failure'
run: exit 1