1- name : CI-Validate Deployment-CKM-V2
1+ name : CI-Validate Deployment-KM-Generic
22on :
33 push :
44 branches :
5- - ckm-v2
5+
6+ - main
7+ - dev
8+ - demo
9+
610 schedule :
711 - cron : ' 0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
812
@@ -30,51 +34,41 @@ jobs:
3034 run : |
3135 echo "Generating a unique resource group name..."
3236 TIMESTAMP=$(date +%Y%m%d%H%M%S)
33- COMMON_PART="ci-ckmv2 "
37+ COMMON_PART="ci-KMGeneric "
3438 UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
3539 echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
3640 echo "Generated Resource_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
3741
3842 - name : Create Resource Group
3943 run : |
40- az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location eastus
44+ az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location westeurope
4145
4246 - name : Generate Unique Solution Prefix
4347 id : generate_solution_prefix
4448 run : |
4549 set -e
46- COMMON_PART="ckm2 "
50+ COMMON_PART="km "
4751 TIMESTAMP=$(date +%s)
4852 UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 3)
4953 UNIQUE_SOLUTION_PREFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
5054 echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
5155 echo "Generated SOLUTION_PREFIX: ${UNIQUE_SOLUTION_PREFIX}"
5256
57+
58+ - name : Determine Tag Name Based on Branch
59+ id : determine_tag
60+ run : echo "tagname=${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref || 'default' }}" >> $GITHUB_OUTPUT
61+
5362 - name : Deploy Bicep Template
5463 id : deploy
5564 run : |
5665 set -e
5766 az deployment group create \
5867 --resource-group ${{ env.RESOURCE_GROUP_NAME }} \
5968 --template-file Deployment/bicep/main.bicep \
60- --parameters solutionPrefix=${{ env.SOLUTION_PREFIX }} location=eastus
69+ --parameters solutionPrefix=${{ env.SOLUTION_PREFIX }} otherLocation=centralus imageTag=${{ steps.determine_tag.outputs.tagname }}
6170
62- - name : Delete Bicep Deployment
63- if : success()
64- run : |
65- set -e
66- echo "Checking if resource group exists..."
67- rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
68- if [ "$rg_exists" = "true" ]; then
69- echo "Resource group exist. Cleaning..."
70- az group delete \
71- --name ${{ env.RESOURCE_GROUP_NAME }} \
72- --yes \
73- --no-wait
74- echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
75- else
76- echo "Resource group does not exists."
77- fi
71+
7872
7973 - name : Send Notification on Failure
8074 if : failure()
9387 curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
9488 -H "Content-Type : application/json" \
9589 -d "$EMAIL_BODY" || echo "Failed to send notification"
90+
91+
92+ - name : Delete Bicep Deployment
93+
94+ run : |
95+ set -e
96+ echo "Checking if resource group exists..."
97+ rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
98+ if [ "$rg_exists" = "true" ]; then
99+ echo "Resource group exist. Cleaning..."
100+ az group delete \
101+ --name ${{ env.RESOURCE_GROUP_NAME }} \
102+ --yes \
103+ --no-wait
104+ echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
105+ else
106+ echo "Resource group does not exists."
107+ fi
108+
0 commit comments