3535 SANDBOX_NAME : ${{ github.event.inputs.sandbox_name }}
3636
3737 # Checkout the repository to the GitHub Actions runner
38- - name : Checkout Base
38+ - name : Checkout main
3939 uses : actions/checkout@v5
4040 with :
4141 ref : main
@@ -58,58 +58,64 @@ jobs:
5858 terraform_version : 1.11.4
5959 terraform_wrapper : false
6060
61- - name : Terraform Init Base
62- id : base_init
61+ - name : Terraform Init main
62+ id : main_init
6363 run : terraform init -backend-config=backend.conf
6464 working-directory : ./infrastructure
6565 shell : bash
6666
67- - name : Terraform Set Workspace Base
68- id : base_workspace
67+ - name : Terraform Set Workspace
68+ id : main_workspace
6969 run : terraform workspace select -or-create ${{ github.event.inputs.sandbox_name}}
7070 working-directory : ./infrastructure
7171 shell : bash
7272
73- - name : Terraform Plan Base
74- id : base_plan
73+ - name : Terraform Plan main
74+ id : main_plan
7575 run : |
76- terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf-base .plan
76+ terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf-main .plan
7777 working-directory : ./infrastructure
7878 shell : bash
7979
80- - name : Terraform Apply Base
81- run : terraform apply -auto-approve -input=false tf-base .plan
80+ - name : Terraform Apply main
81+ run : terraform apply -auto-approve -input=false tf-main .plan
8282 working-directory : ./infrastructure
8383
8484 - name : Checkout Branch
85+ if : ${{ github.event.inputs.git_ref != 'main' }}
8586 uses : actions/checkout@v5
8687 with :
8788 ref : ${{ github.event.inputs.git_ref}}
8889
8990 # Checks that all Terraform configuration files adhere to a canonical format.
90- - name : Terraform Format
91+ - name : Terraform Format Branch
92+ if : ${{ github.event.inputs.git_ref != 'main' }}
9193 run : terraform fmt -check
9294 working-directory : ./infrastructure
9395
94- - name : Terraform Init
96+ - name : Terraform Init Branch
97+ if : ${{ github.event.inputs.git_ref != 'main' }}
9598 id : init
9699 run : terraform init -backend-config=backend.conf
97100 working-directory : ./infrastructure
98101 shell : bash
99102
100103 - name : Terraform Set Workspace
104+ if : ${{ github.event.inputs.git_ref != 'main' }}
101105 id : workspace
102106 run : terraform workspace select ${{ github.event.inputs.sandbox_name}}
103107 working-directory : ./infrastructure
104108 shell : bash
105109
106- - name : Terraform Plan
110+ - name : Terraform Plan Branch
111+ if : ${{ github.event.inputs.git_ref != 'main' }}
107112 id : plan
108113 run : |
109114 terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan
110115 working-directory : ./infrastructure
111116 shell : bash
112117
113- - name : Terraform Apply
118+ - name : Terraform Apply Branch (over main)
119+ if : ${{ github.event.inputs.git_ref != 'main' }}
114120 run : terraform apply -auto-approve -input=false tf.plan
115121 working-directory : ./infrastructure
0 commit comments