Skip to content

Commit 5cfb9e9

Browse files
committed
Add Concurrency in Workflow & TF Unlock
1 parent ec63e08 commit 5cfb9e9

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

.github/workflows/_functionAppDeployTemplate.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
runs-on: [self-hosted]
4444
continue-on-error: false
4545
environment: ${{ inputs.environment }}
46+
concurrency:
47+
group: function-${{ inputs.function_name }}-${{ inputs.environment }}
48+
cancel-in-progress: false
4649

4750
steps:
4851
# Check Out Repository

.github/workflows/_terraformEnvironmentTemplate.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ jobs:
100100
continue-on-error: false
101101
environment: ${{ inputs.environment }}
102102
needs: [lint]
103+
concurrency:
104+
group: terraform-${{ inputs.config }}-${{ inputs.environment }}
105+
cancel-in-progress: false
103106

104107
env:
105108
ARM_TENANT_ID: ${{ inputs.tenant_id }}
@@ -188,13 +191,25 @@ jobs:
188191
body: output
189192
})
190193
194+
# Terraform State Unlock
195+
- name: Terraform State Unlock
196+
working-directory: ${{ inputs.working_directory }}
197+
if: cancelled()
198+
run: |
199+
LOCK_ID=`jq -r '.ID' .terraform.tfstate.lock.info`
200+
echo $LOCK_ID
201+
terraform force-unlock -force $LOCK_ID
202+
191203
apply:
192204
name: Terraform Apply
193205
runs-on: [self-hosted]
194206
continue-on-error: false
195207
environment: ${{ inputs.environment }}
196208
if: github.event_name == 'push' || github.event_name == 'release'
197209
needs: [plan]
210+
concurrency:
211+
group: terraform-${{ inputs.config }}-${{ inputs.environment }}
212+
cancel-in-progress: false
198213

199214
env:
200215
ARM_TENANT_ID: ${{ inputs.tenant_id }}
@@ -240,3 +255,12 @@ jobs:
240255
env:
241256
CONFIG: ${{ inputs.config }}
242257
TF_VAR_my_secret: ${{ secrets.MY_SAMPLE_SECRET }}
258+
259+
# Terraform State Unlock
260+
- name: Terraform State Unlock
261+
working-directory: ${{ inputs.working_directory }}
262+
if: cancelled()
263+
run: |
264+
LOCK_ID=`jq -r '.ID' .terraform.tfstate.lock.info`
265+
echo $LOCK_ID
266+
terraform force-unlock -force $LOCK_ID

0 commit comments

Comments
 (0)