You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
86
+
if [ "$rg_exists" = "true" ]; then
87
+
echo "Resource group exists. Cleaning..."
88
+
az group delete \
89
+
--name ${{ env.RESOURCE_GROUP_NAME }} \
90
+
--yes \
91
+
--no-wait
92
+
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
93
+
else
94
+
echo "Resource group does not exist."
95
+
fi
96
+
97
+
- name: Wait for Resource Deletion to Complete
98
+
run: |
99
+
# List of resources to check based on SOLUTION_PREFIX
100
+
resources_to_check=(
101
+
"aoai-${{ env.SOLUTION_PREFIX }}"
102
+
"appins-${{ env.SOLUTION_PREFIX }}"
103
+
"db-cosmos-${{ env.SOLUTION_PREFIX }}"
104
+
"${{ env.SOLUTION_PREFIX }}-plan"
105
+
"search-${{ env.SOLUTION_PREFIX }}"
106
+
"webapp-${{ env.SOLUTION_PREFIX }}"
107
+
"worksp-${{ env.SOLUTION_PREFIX }}"
108
+
)
109
+
110
+
# Get the list of resources in YAML format
111
+
resource_list=$(az resource list --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} --output yaml)
112
+
113
+
# Maximum number of retries and retry intervals
114
+
max_retries=3
115
+
retry_intervals=(30 60 120)
116
+
retries=0
117
+
118
+
while true; do
119
+
resource_found=false
120
+
# Iterate through the resources to check
121
+
for resource in "${resources_to_check[@]}"; do
122
+
echo "Checking resource: $resource"
123
+
if echo "$resource_list" | grep -q "name: $resource"; then
124
+
echo "Resource '$resource' exists in the subscription."
125
+
resource_found=true
126
+
else
127
+
echo "Resource '$resource' does not exist in the subscription."
128
+
fi
129
+
done
130
+
131
+
# If any resource exists, retry
132
+
if [ "$resource_found" = true ]; then
133
+
retries=$((retries + 1))
134
+
if [ "$retries" -ge "$max_retries" ]; then
135
+
echo "Maximum retry attempts reached. Exiting."
136
+
break
137
+
else
138
+
echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
139
+
sleep ${retry_intervals[$retries-1]}
140
+
fi
141
+
else
142
+
echo "No resources found. Exiting."
143
+
break
144
+
fi
145
+
done
146
+
147
+
- name: Purging the Resources
148
+
if: success()
149
+
run: |
150
+
set -e
151
+
# Purging resources based on solution prefix
152
+
echo "Purging resources..."
153
+
154
+
# List of resources to purge
155
+
resources_to_purge=(
156
+
"aoai-${{ env.SOLUTION_PREFIX }}"
157
+
"appins-${{ env.SOLUTION_PREFIX }}"
158
+
"db-cosmos-${{ env.SOLUTION_PREFIX }}"
159
+
"${{ env.SOLUTION_PREFIX }}-plan"
160
+
"search-${{ env.SOLUTION_PREFIX }}"
161
+
"webapp-${{ env.SOLUTION_PREFIX }}"
162
+
"worksp-${{ env.SOLUTION_PREFIX }}"
163
+
)
164
+
165
+
for resource in "${resources_to_purge[@]}"; do
166
+
echo "Purging resource: $resource"
167
+
if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/uksouth/deletedAccounts/$resource --verbose; then
"body": "<p>Dear Team,</p><p>We would like to inform you that the Research Assistant 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>"
184
+
}
185
+
EOF
186
+
)
187
+
188
+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
189
+
-H "Content-Type: application/json" \
190
+
-d "$EMAIL_BODY" || echo "Failed to send notification"
0 commit comments