Skip to content

Commit d6aa464

Browse files
testing automation flow
1 parent 693dcd3 commit d6aa464

File tree

1 file changed

+149
-122
lines changed

1 file changed

+149
-122
lines changed

.github/workflows/deploy.yml

Lines changed: 149 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
echo "Generating a unique resource group name..."
3131
TIMESTAMP=$(date +%Y%m%d%H%M%S)
3232
COMMON_PART="ci-biab"
33-
UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
33+
# UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
34+
UNIQUE_RG_NAME="rg-biab-hotfix"
3435
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
3536
echo "Generated Resource_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
3637
@@ -49,33 +50,33 @@ jobs:
4950
fi
5051
5152
52-
- name: Deploy Bicep Template
53-
id: deploy
54-
run: |
55-
set -e
56-
az deployment group create \
57-
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
58-
--template-file deploy/macae.bicep \
59-
--parameters azureOpenAILocation=eastus2 cosmosLocation=eastus2
53+
# - name: Deploy Bicep Template
54+
# id: deploy
55+
# run: |
56+
# set -e
57+
# az deployment group create \
58+
# --resource-group ${{ env.RESOURCE_GROUP_NAME }} \
59+
# --template-file deploy/macae.bicep \
60+
# --parameters azureOpenAILocation=eastus2 cosmosLocation=eastus2
6061

6162

62-
- name: Send Notification on Failure
63-
if: failure()
64-
run: |
65-
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
63+
# - name: Send Notification on Failure
64+
# if: failure()
65+
# run: |
66+
# RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
6667

67-
# Construct the email body
68-
EMAIL_BODY=$(cat <<EOF
69-
{
70-
"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>"
71-
}
72-
EOF
73-
)
68+
# # Construct the email body
69+
# EMAIL_BODY=$(cat <<EOF
70+
# {
71+
# "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>"
72+
# }
73+
# EOF
74+
# )
7475

75-
# Send the notification
76-
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
77-
-H "Content-Type: application/json" \
78-
-d "$EMAIL_BODY" || echo "Failed to send notification"
76+
# # Send the notification
77+
# curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
78+
# -H "Content-Type: application/json" \
79+
# -d "$EMAIL_BODY" || echo "Failed to send notification"
7980

8081

8182
- name: Get OpenAI, Container Registry Resource from Resource Group
@@ -110,112 +111,138 @@ jobs:
110111
echo "Azure Container Registry name: ${acr_name}"
111112
fi
112113
113-
114-
- name: Build the image and update the container app
115-
id: build-and-update
114+
- name: Get Azure App Service Resource from Resource Group
115+
id: get_app_service_resource
116116
run: |
117-
118117
set -e
119-
# Define variables for acr and container app names
120-
acr_name="${{ env.ACR_NAME }}"
121-
echo "ACR name: {$acr_name}"
122-
container_app_name="biab"
123-
buildImageTag="biab:latest"
124-
125-
echo "Building the container image..."
126-
# Build the image
127-
az acr build -r ${acr_name} -t ${buildImageTag} ./agnext-biab-02
128-
echo "Image build completed successfully."
129-
130-
echo "Updating the container app..."
131-
# Update the container app
132-
az containerapp update -n ${container_app_name} -g ${{ env.RESOURCE_GROUP_NAME }} --image ${acr_name}.azurecr.io/${buildImageTag}
133-
echo "Container app update completed successfully."
134-
118+
echo "Fetching Azure App Service resource from resource group ${{ env.RESOURCE_GROUP_NAME }}..."
135119
136-
- name: Delete Bicep Deployment
137-
if: success()
138-
run: |
139-
set -e
140-
echo "Checking if resource group exists..."
141-
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
142-
if [ "$rg_exists" = "true" ]; then
143-
echo "Resource group exist. Cleaning..."
144-
az group delete \
145-
--name ${{ env.RESOURCE_GROUP_NAME }} \
146-
--yes \
147-
--no-wait
148-
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
120+
# Run the az resource list command to get the App Service resource name
121+
app_service_name=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --resource-type "Microsoft.Web/sites" --query "[0].name" -o tsv)
122+
123+
if [ -z "$app_service_name" ]; then
124+
echo "No Azure App Service resource found in resource group ${{ env.RESOURCE_GROUP_NAME }}."
125+
exit 1
149126
else
150-
echo "Resource group does not exists."
127+
echo "APP_SERVICE_NAME=${app_service_name}" >> $GITHUB_ENV
128+
echo "Azure App Service resource name: ${app_service_name}"
151129
fi
152130
153131
154-
- name: Wait for resource deletion to complete
155-
run: |
156-
132+
133+
# - name: Build the image and update the container app
134+
# id: build-and-update
135+
# run: |
136+
137+
# set -e
138+
# # Define variables for acr and container app names
139+
# acr_name="${{ env.ACR_NAME }}"
140+
# echo "ACR name: {$acr_name}"
141+
# backend_container_app_name="macae-backend"
142+
# buildImageTag="backend:latest"
143+
144+
# echo "Building the container image..."
145+
# # Build the image
146+
# az acr build -r ${acr_name} -t ${buildImageTag} ./agnext-biab-02
147+
# echo "Backend image build completed successfully."
148+
149+
# echo "Updating the container app..."
150+
# # Update the container app
151+
# az containerapp update -n ${container_app_name} -g ${{ env.RESOURCE_GROUP_NAME }} --image ${acr_name}.azurecr.io/${buildImageTag}
152+
# echo "Backend container app update completed successfully."
153+
154+
# frontend_container_app_name="macae-backend"
155+
# buildImageTag="backend:latest"
156+
157+
# echo "Building the container image..."
158+
# # Build the image
159+
# az acr build -r ${acr_name} -t ${buildImageTag} ./agnext-biab-02
160+
# echo "Image build completed successfully."
161+
157162

158-
# Add resources to the array
159-
resources_to_check=("${{ env.OPENAI_RESOURCE_NAME }}")
160-
161-
echo "List of resources to check: ${resources_to_check[@]}"
162-
163-
# Maximum number of retries
164-
max_retries=3
165-
166-
# Retry intervals in seconds (30, 60, 120)
167-
retry_intervals=(30 60 120)
168-
169-
# Retry mechanism to check resources
170-
retries=0
171-
while true; do
172-
resource_found=false
173-
174-
# Get the list of resources in YAML format again on each retry
175-
resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml)
176-
177-
# Iterate through the resources to check
178-
for resource in "${resources_to_check[@]}"; do
179-
echo "Checking resource: $resource"
180-
if echo "$resource_list" | grep -q "name: $resource"; then
181-
echo "Resource '$resource' exists in the resource group."
182-
resource_found=true
183-
else
184-
echo "Resource '$resource' does not exist in the resource group."
185-
fi
186-
done
187-
188-
# If any resource exists, retry
189-
if [ "$resource_found" = true ]; then
190-
retries=$((retries + 1))
191-
if [ "$retries" -gt "$max_retries" ]; then
192-
echo "Maximum retry attempts reached. Exiting."
193-
break
194-
else
195-
# Wait for the appropriate interval for the current retry
196-
echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
197-
sleep ${retry_intervals[$retries-1]}
198-
fi
199-
else
200-
echo "No resources found. Exiting."
201-
break
202-
fi
203-
done
163+
# - name: Delete Bicep Deployment
164+
# if: success()
165+
# run: |
166+
# set -e
167+
# echo "Checking if resource group exists..."
168+
# rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
169+
# if [ "$rg_exists" = "true" ]; then
170+
# echo "Resource group exist. Cleaning..."
171+
# az group delete \
172+
# --name ${{ env.RESOURCE_GROUP_NAME }} \
173+
# --yes \
174+
# --no-wait
175+
# echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
176+
# else
177+
# echo "Resource group does not exists."
178+
# fi
179+
180+
181+
# - name: Wait for resource deletion to complete
182+
# run: |
204183

205184

206-
- name: Purging the Resources
207-
if: success()
208-
run: |
185+
# # Add resources to the array
186+
# resources_to_check=("${{ env.OPENAI_RESOURCE_NAME }}")
187+
188+
# echo "List of resources to check: ${resources_to_check[@]}"
189+
190+
# # Maximum number of retries
191+
# max_retries=3
192+
193+
# # Retry intervals in seconds (30, 60, 120)
194+
# retry_intervals=(30 60 120)
195+
196+
# # Retry mechanism to check resources
197+
# retries=0
198+
# while true; do
199+
# resource_found=false
200+
201+
# # Get the list of resources in YAML format again on each retry
202+
# resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml)
203+
204+
# # Iterate through the resources to check
205+
# for resource in "${resources_to_check[@]}"; do
206+
# echo "Checking resource: $resource"
207+
# if echo "$resource_list" | grep -q "name: $resource"; then
208+
# echo "Resource '$resource' exists in the resource group."
209+
# resource_found=true
210+
# else
211+
# echo "Resource '$resource' does not exist in the resource group."
212+
# fi
213+
# done
214+
215+
# # If any resource exists, retry
216+
# if [ "$resource_found" = true ]; then
217+
# retries=$((retries + 1))
218+
# if [ "$retries" -gt "$max_retries" ]; then
219+
# echo "Maximum retry attempts reached. Exiting."
220+
# break
221+
# else
222+
# # Wait for the appropriate interval for the current retry
223+
# echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
224+
# sleep ${retry_intervals[$retries-1]}
225+
# fi
226+
# else
227+
# echo "No resources found. Exiting."
228+
# break
229+
# fi
230+
# done
209231

210-
set -e
211-
echo "Azure OpenAI: ${{ env.OPENAI_RESOURCE_NAME }}"
212-
213-
# Purge OpenAI Resource
214-
echo "Purging the OpenAI Resource..."
215-
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
216-
echo "Failed to purge openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
217-
else
218-
echo "Purged the openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
219-
fi
220-
221-
echo "Resource purging completed successfully"
232+
233+
# - name: Purging the Resources
234+
# if: success()
235+
# run: |
236+
237+
# set -e
238+
# echo "Azure OpenAI: ${{ env.OPENAI_RESOURCE_NAME }}"
239+
240+
# # Purge OpenAI Resource
241+
# echo "Purging the OpenAI Resource..."
242+
# 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
243+
# echo "Failed to purge openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
244+
# else
245+
# echo "Purged the openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
246+
# fi
247+
248+
# echo "Resource purging completed successfully"

0 commit comments

Comments
 (0)