|
76 | 76 | - name: List KeyVaults and Store in Array |
77 | 77 | id: list_keyvaults |
78 | 78 | run: | |
| 79 | +
|
79 | 80 | set -e |
80 | 81 | echo "Listing all KeyVaults in the resource group ${RESOURCE_GROUP_NAME}..." |
81 | 82 | |
@@ -108,6 +109,7 @@ jobs: |
108 | 109 | - name: Update PowerBI URL |
109 | 110 | if: success() |
110 | 111 | run: | |
| 112 | +
|
111 | 113 | set -e |
112 | 114 |
|
113 | 115 | COMMON_PART="-app-service" |
@@ -144,12 +146,65 @@ jobs: |
144 | 146 |
|
145 | 147 | - name: Wait for resource deletion to complete |
146 | 148 | run: | |
147 | | - echo "Waiting for resource group deletion to complete..." |
148 | | - sleep 120 # Wait for 2 minutes (120 seconds) to allow deletion to complete |
| 149 | +
|
| 150 | + # List of keyvaults |
| 151 | + KEYVAULTS="${{ env.KEYVAULTS }}" |
| 152 | +
|
| 153 | + # Remove the surrounding square brackets, if they exist |
| 154 | + stripped_keyvaults=$(echo "$KEYVAULTS" | sed 's/\[\|\]//g') |
| 155 | + |
| 156 | + # Convert the comma-separated string into an array |
| 157 | + IFS=',' read -r -a resources_to_check <<< "$stripped_keyvaults" |
| 158 | + |
| 159 | + # Append new resources to the array |
| 160 | + resources_to_check+=("${{ env.SOLUTION_PREFIX }}-openai" "${{ env.SOLUTION_PREFIX }}-cogser") |
| 161 | +
|
| 162 | + echo "List of resources to check: ${resources_to_check[@]}" |
| 163 | + |
| 164 | + # Get the list of resources in YAML format |
| 165 | + resource_list=$(az resource list --resource-group myResourceGroup4 --output yaml) |
| 166 | +
|
| 167 | + # Maximum number of retries |
| 168 | + max_retries=3 |
| 169 | +
|
| 170 | + # Retry intervals in seconds (30, 60, 120) |
| 171 | + retry_intervals=(30 60 120) |
| 172 | +
|
| 173 | + while true; do |
| 174 | + resource_found=false |
| 175 | +
|
| 176 | + # Iterate through the resources to check |
| 177 | + for resource in "${resources_to_check[@]}"; do |
| 178 | + echo "Checking resource: $resource" |
| 179 | + if echo "$resource_list" | grep -q "name: $resource"; then |
| 180 | + echo "Resource '$resource' exists in the resource group." |
| 181 | + resource_found=true |
| 182 | + else |
| 183 | + echo "Resource '$resource' does not exist in the resource group." |
| 184 | + fi |
| 185 | + done |
| 186 | +
|
| 187 | + # If any resource exists, retry |
| 188 | + if [ "$resource_found" = true ]; then |
| 189 | + retries=$((retries + 1)) |
| 190 | + if [ "$retries" -ge "$max_retries" ]; then |
| 191 | + echo "Maximum retry attempts reached. Exiting." |
| 192 | + break |
| 193 | + else |
| 194 | + # Wait for the appropriate interval for the current retry |
| 195 | + echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..." |
| 196 | + sleep ${retry_intervals[$retries-1]} |
| 197 | + fi |
| 198 | + else |
| 199 | + echo "No resources found. Exiting." |
| 200 | + break |
| 201 | + fi |
| 202 | + done |
149 | 203 |
|
150 | 204 | - name: Purging the Resources |
151 | 205 | if: success() |
152 | 206 | run: | |
| 207 | +
|
153 | 208 | set -e |
154 | 209 | # Define variables |
155 | 210 | OPENAI_COMMON_PART="-openai" |
@@ -205,6 +260,7 @@ jobs: |
205 | 260 | - name: Send Notification on Failure |
206 | 261 | if: failure() |
207 | 262 | run: | |
| 263 | +
|
208 | 264 | RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
209 | 265 | |
210 | 266 | # Construct the email body |
|
0 commit comments