forked from soulpage/fullstack-assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (58 loc) · 1.66 KB
/
tf.yml
File metadata and controls
70 lines (58 loc) · 1.66 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
67
68
69
70
name: Terraform Deployment Workflow
on:
push:
branches:
- ujwal-cicd
- ujwal-tf
paths:
- ".github/workflows/tf.yml"
- "tf/files/**"
pull_request:
types: [synchronize]
workflow_dispatch:
defaults:
run:
shell: bash
working-directory: tf/files/
permissions:
actions: read
contents: read
pull-requests: write
env:
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
Terraform-Deployment:
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.8"
- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate
- name: Terraform Plan
id: plan
run: terraform plan -var-file=variables.tfvars -out=tfplan
continue-on-error: true
- name: Terraform Apply
if: "contains(github.event.head_commit.message, 'Apply')"
id: apply
run: terraform apply -var-file=variables.tfvars --auto-approve
- name: Terraform Destroy
if: "contains(github.event.head_commit.message, 'Destroy')"
id: destroy
run: terraform destroy -var-file=variables.tfvars --auto-approve