@@ -192,160 +192,160 @@ jobs:
192192 MACAE_CONTAINER_APP : ${{ needs.deploy.outputs.CONTAINER_APP }}
193193 secrets : inherit
194194
195- cleanup-deployment :
196- if : always() && needs.deploy.outputs.RESOURCE_GROUP_NAME != ''
197- needs : [deploy, e2e-test]
198- runs-on : ubuntu-latest
199- env :
200- RESOURCE_GROUP_NAME : ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
201- steps :
202- - name : Setup Azure CLI
203- run : |
204- curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
205- az --version
206- - name : Login to Azure
207- run : |
208- az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
209- az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
210-
211- - name : Extract AI Services and Key Vault Names
212- if : always()
213- run : |
214- echo "Fetching AI Services and Key Vault names before deletion..."
215-
216- # Get Key Vault name
217- KEYVAULT_NAME=$(az resource list --resource-group "${{ env.RESOURCE_GROUP_NAME }}" --resource-type "Microsoft.KeyVault/vaults" --query "[].name" -o tsv)
218- echo "Detected Key Vault: $KEYVAULT_NAME"
219- echo "KEYVAULT_NAME=$KEYVAULT_NAME" >> $GITHUB_ENV
220- # Extract AI Services names
221- echo "Fetching AI Services..."
222- AI_SERVICES=$(az resource list --resource-group '${{ env.RESOURCE_GROUP_NAME }}' --resource-type "Microsoft.CognitiveServices/accounts" --query "[].name" -o tsv)
223- # Flatten newline-separated values to space-separated
224- AI_SERVICES=$(echo "$AI_SERVICES" | paste -sd ' ' -)
225- echo "Detected AI Services: $AI_SERVICES"
226- echo "AI_SERVICES=$AI_SERVICES" >> $GITHUB_ENV
227-
228- - name : Get OpenAI Resource from Resource Group
229- id : get_openai_resource
230- run : |
231-
232- set -e
233- echo "Fetching OpenAI resource from resource group ${{ env.RESOURCE_GROUP_NAME }}..."
234-
235- # Run the az resource list command to get the OpenAI resource name
236- openai_resource_name=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --resource-type "Microsoft.CognitiveServices/accounts" --query "[0].name" -o tsv)
237-
238- if [ -z "$openai_resource_name" ]; then
239- echo "No OpenAI resource found in resource group ${{ env.RESOURCE_GROUP_NAME }}."
240- exit 0
241- else
242- echo "OPENAI_RESOURCE_NAME=${openai_resource_name}" >> $GITHUB_ENV
243- echo "OpenAI resource name: ${openai_resource_name}"
244- fi
245-
246- - name : Delete Bicep Deployment
247- if : always()
248- run : |
249- set -e
250- echo "Checking if resource group exists..."
251- rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
252- if [ "$rg_exists" = "true" ]; then
253- echo "Resource group exist. Cleaning..."
254- az group delete \
255- --name ${{ env.RESOURCE_GROUP_NAME }} \
256- --yes \
257- --no-wait
258- echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
259- else
260- echo "Resource group does not exists."
261- fi
262-
263- - name : Wait for resource deletion to complete
264- run : |
265-
266- # Add resources to the array
267- resources_to_check=("${{ env.OPENAI_RESOURCE_NAME }}")
268-
269- echo "List of resources to check: ${resources_to_check[@]}"
270-
271- # Maximum number of retries
272- max_retries=3
273-
274- # Retry intervals in seconds (30, 60, 120)
275- retry_intervals=(30 60 120)
276-
277- # Retry mechanism to check resources
278- retries=0
279- while true; do
280- resource_found=false
281-
282- # Get the list of resources in YAML format again on each retry
283- resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml)
284-
285- # Iterate through the resources to check
286- for resource in "${resources_to_check[@]}"; do
287- echo "Checking resource: $resource"
288- if echo "$resource_list" | grep -q "name: $resource"; then
289- echo "Resource '$resource' exists in the resource group."
290- resource_found=true
291- else
292- echo "Resource '$resource' does not exist in the resource group."
293- fi
294- done
295-
296- # If any resource exists, retry
297- if [ "$resource_found" = true ]; then
298- retries=$((retries + 1))
299- if [ "$retries" -gt "$max_retries" ]; then
300- echo "Maximum retry attempts reached. Exiting."
301- break
302- else
303- # Wait for the appropriate interval for the current retry
304- echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
305- sleep ${retry_intervals[$retries-1]}
306- fi
307- else
308- echo "No resources found. Exiting."
309- break
310- fi
311- done
312-
313- - name : Purging the Resources
314- if : always()
315- run : |
316-
317- set -e
318- echo "Azure OpenAI: ${{ env.OPENAI_RESOURCE_NAME }}"
319-
320- # Purge OpenAI Resource
321- echo "Purging the OpenAI Resource..."
322- if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/eastus/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/${{ env.OPENAI_RESOURCE_NAME }} --verbose; then
323- echo "Failed to purge openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
324- else
325- echo "Purged the openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
326- fi
327-
328- echo "Resource purging completed successfully"
329-
330- - name : Send Notification on Failure
331- if : failure()
332- run : |
333- RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
334-
335- # Construct the email body
336- EMAIL_BODY=$(cat <<EOF
337- {
338- "body": "<p>Dear Team,</p><p>We would like to inform you that the Multi-Agent-Custom-Automation-Engine-Solution-Accelerator Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
339- }
340- EOF
341- )
342-
343- # Send the notification
344- curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
345- -H "Content-Type: application/json" \
346- -d "$EMAIL_BODY" || echo "Failed to send notification"
347- - name : Logout from Azure
348- if : always()
349- run : |
350- az logout
351- echo "Logged out from Azure."
195+ # cleanup-deployment:
196+ # if: always() && needs.deploy.outputs.RESOURCE_GROUP_NAME != ''
197+ # needs: [deploy, e2e-test]
198+ # runs-on: ubuntu-latest
199+ # env:
200+ # RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
201+ # steps:
202+ # - name: Setup Azure CLI
203+ # run: |
204+ # curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
205+ # az --version
206+ # - name: Login to Azure
207+ # run: |
208+ # az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
209+ # az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
210+
211+ # - name: Extract AI Services and Key Vault Names
212+ # if: always()
213+ # run: |
214+ # echo "Fetching AI Services and Key Vault names before deletion..."
215+
216+ # # Get Key Vault name
217+ # KEYVAULT_NAME=$(az resource list --resource-group "${{ env.RESOURCE_GROUP_NAME }}" --resource-type "Microsoft.KeyVault/vaults" --query "[].name" -o tsv)
218+ # echo "Detected Key Vault: $KEYVAULT_NAME"
219+ # echo "KEYVAULT_NAME=$KEYVAULT_NAME" >> $GITHUB_ENV
220+ # # Extract AI Services names
221+ # echo "Fetching AI Services..."
222+ # AI_SERVICES=$(az resource list --resource-group '${{ env.RESOURCE_GROUP_NAME }}' --resource-type "Microsoft.CognitiveServices/accounts" --query "[].name" -o tsv)
223+ # # Flatten newline-separated values to space-separated
224+ # AI_SERVICES=$(echo "$AI_SERVICES" | paste -sd ' ' -)
225+ # echo "Detected AI Services: $AI_SERVICES"
226+ # echo "AI_SERVICES=$AI_SERVICES" >> $GITHUB_ENV
227+
228+ # - name: Get OpenAI Resource from Resource Group
229+ # id: get_openai_resource
230+ # run: |
231+
232+ # set -e
233+ # echo "Fetching OpenAI resource from resource group ${{ env.RESOURCE_GROUP_NAME }}..."
234+
235+ # # Run the az resource list command to get the OpenAI resource name
236+ # openai_resource_name=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --resource-type "Microsoft.CognitiveServices/accounts" --query "[0].name" -o tsv)
237+
238+ # if [ -z "$openai_resource_name" ]; then
239+ # echo "No OpenAI resource found in resource group ${{ env.RESOURCE_GROUP_NAME }}."
240+ # exit 0
241+ # else
242+ # echo "OPENAI_RESOURCE_NAME=${openai_resource_name}" >> $GITHUB_ENV
243+ # echo "OpenAI resource name: ${openai_resource_name}"
244+ # fi
245+
246+ # - name: Delete Bicep Deployment
247+ # if: always()
248+ # run: |
249+ # set -e
250+ # echo "Checking if resource group exists..."
251+ # rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
252+ # if [ "$rg_exists" = "true" ]; then
253+ # echo "Resource group exist. Cleaning..."
254+ # az group delete \
255+ # --name ${{ env.RESOURCE_GROUP_NAME }} \
256+ # --yes \
257+ # --no-wait
258+ # echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
259+ # else
260+ # echo "Resource group does not exists."
261+ # fi
262+
263+ # - name: Wait for resource deletion to complete
264+ # run: |
265+
266+ # # Add resources to the array
267+ # resources_to_check=("${{ env.OPENAI_RESOURCE_NAME }}")
268+
269+ # echo "List of resources to check: ${resources_to_check[@]}"
270+
271+ # # Maximum number of retries
272+ # max_retries=3
273+
274+ # # Retry intervals in seconds (30, 60, 120)
275+ # retry_intervals=(30 60 120)
276+
277+ # # Retry mechanism to check resources
278+ # retries=0
279+ # while true; do
280+ # resource_found=false
281+
282+ # # Get the list of resources in YAML format again on each retry
283+ # resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml)
284+
285+ # # Iterate through the resources to check
286+ # for resource in "${resources_to_check[@]}"; do
287+ # echo "Checking resource: $resource"
288+ # if echo "$resource_list" | grep -q "name: $resource"; then
289+ # echo "Resource '$resource' exists in the resource group."
290+ # resource_found=true
291+ # else
292+ # echo "Resource '$resource' does not exist in the resource group."
293+ # fi
294+ # done
295+
296+ # # If any resource exists, retry
297+ # if [ "$resource_found" = true ]; then
298+ # retries=$((retries + 1))
299+ # if [ "$retries" -gt "$max_retries" ]; then
300+ # echo "Maximum retry attempts reached. Exiting."
301+ # break
302+ # else
303+ # # Wait for the appropriate interval for the current retry
304+ # echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
305+ # sleep ${retry_intervals[$retries-1]}
306+ # fi
307+ # else
308+ # echo "No resources found. Exiting."
309+ # break
310+ # fi
311+ # done
312+
313+ # - name: Purging the Resources
314+ # if: always()
315+ # run: |
316+
317+ # set -e
318+ # echo "Azure OpenAI: ${{ env.OPENAI_RESOURCE_NAME }}"
319+
320+ # # Purge OpenAI Resource
321+ # echo "Purging the OpenAI Resource..."
322+ # if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/eastus/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/${{ env.OPENAI_RESOURCE_NAME }} --verbose; then
323+ # echo "Failed to purge openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
324+ # else
325+ # echo "Purged the openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
326+ # fi
327+
328+ # echo "Resource purging completed successfully"
329+
330+ # - name: Send Notification on Failure
331+ # if: failure()
332+ # run: |
333+ # RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
334+
335+ # # Construct the email body
336+ # EMAIL_BODY=$(cat <<EOF
337+ # {
338+ # "body": "<p>Dear Team,</p><p>We would like to inform you that the Multi-Agent-Custom-Automation-Engine-Solution-Accelerator Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
339+ # }
340+ # EOF
341+ # )
342+
343+ # # Send the notification
344+ # curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
345+ # -H "Content-Type: application/json" \
346+ # -d "$EMAIL_BODY" || echo "Failed to send notification"
347+ # - name: Logout from Azure
348+ # if: always()
349+ # run: |
350+ # az logout
351+ # echo "Logged out from Azure."
0 commit comments