10
10
defaults :
11
11
run :
12
12
working-directory : ./tf-variables/
13
+ env :
14
+ TERRAFORM_VER : 1.8.0
15
+ TERRAFORM_DIR : ./tf-variables
16
+ CLOUDSDK_VER : 480.0.0
13
17
permissions :
14
18
pull-requests : write
15
19
jobs :
@@ -26,17 +30,19 @@ jobs:
26
30
id : checkout_code
27
31
uses : actions/checkout@v2
28
32
29
- # Static code analysis
33
+ # Static code analysis using aqua security's tfsec
30
34
- name : Run tfsec scan
31
35
id : static_code_analysis
32
36
uses : aquasecurity/tfsec-action@v1.0.3
33
37
with :
34
- path : .
38
+ path : ${{ env.TERRAFORM_DIR }}
35
39
36
40
# Install the latest version of Google Cloud SDK
37
41
- id : cloud_sdk_installation
38
42
name : Set up Cloud SDK
39
43
uses : google-github-actions/setup-gcloud@v0.3.0
44
+ with :
45
+ version : ${{ env.CLOUDSDK_VER }}
40
46
41
47
# Setup the authentication for the Google Cloud using WIF
42
48
- id : gcp_auth
@@ -52,27 +58,27 @@ jobs:
52
58
name : Terraform Installation
53
59
uses : hashicorp/setup-terraform@v3
54
60
with :
55
- terraform_version : " 1.8.0 "
61
+ terraform_version : ${{ env.TERRAFORM_VER }}
56
62
57
63
# Checks that Terraform configuration files adhere to a canonical format
58
64
- name : Terraform fmt
59
- id : fmt
65
+ id : tf_fmt
60
66
run : terraform fmt -check
61
67
continue-on-error : true
62
68
63
69
# Initialize the Terraform working directory
64
70
- name : Terraform Init
65
- id : init
71
+ id : tf_init
66
72
run : terraform init
67
73
68
74
# Validate the terraform configuration files
69
75
- name : Terraform Validate
70
- id : validate
76
+ id : tf_validate
71
77
run : terraform validate -no-color
72
78
73
79
# Generates an execution plan for Terraform
74
80
- name : Terraform Plan
75
- id : plan
81
+ id : tf_plan
76
82
run : terraform plan -no-color
77
83
continue-on-error : true
78
84
@@ -115,8 +121,8 @@ jobs:
115
121
body : output
116
122
})
117
123
118
- # Generates an execution plan for Terraform
124
+ # Executes the apply operation to deploy the actual infrastructure
119
125
- name : Terraform Apply
120
- id : apply
126
+ id : tf_apply
121
127
if : github.ref == 'refs/heads/"master"' && github.event_name == 'push'
122
128
run : terraform apply -auto-approve
0 commit comments