|
6 | 6 | - main |
7 | 7 | paths: |
8 | 8 | - 'ClientAdvisor/**' |
9 | | - schedule: |
10 | | - - cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT |
| 9 | + workflow_dispatch: |
| 10 | + # schedule: |
| 11 | + # - cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT |
11 | 12 |
|
12 | 13 | jobs: |
13 | 14 | deploy: |
@@ -126,153 +127,153 @@ jobs: |
126 | 127 |
|
127 | 128 | echo "Power BI URL updated successfully for application: $application_name." |
128 | 129 |
|
129 | | - - name: Delete Bicep Deployment |
130 | | - if: success() |
131 | | - run: | |
132 | | - set -e |
133 | | - echo "Checking if resource group exists..." |
134 | | - rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }}) |
135 | | - if [ "$rg_exists" = "true" ]; then |
136 | | - echo "Resource group exist. Cleaning..." |
137 | | - az group delete \ |
138 | | - --name ${{ env.RESOURCE_GROUP_NAME }} \ |
139 | | - --yes \ |
140 | | - --no-wait |
141 | | - echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}" |
142 | | - else |
143 | | - echo "Resource group does not exists." |
144 | | - fi |
145 | | -
|
146 | | - - name: Wait for resource deletion to complete |
147 | | - run: | |
148 | | -
|
149 | | - # List of keyvaults |
150 | | - KEYVAULTS="${{ env.KEYVAULTS }}" |
151 | | -
|
152 | | - # Remove the surrounding square brackets, if they exist |
153 | | - stripped_keyvaults=$(echo "$KEYVAULTS" | sed 's/\[\|\]//g') |
| 130 | + # - name: Delete Bicep Deployment |
| 131 | + # if: success() |
| 132 | + # run: | |
| 133 | + # set -e |
| 134 | + # echo "Checking if resource group exists..." |
| 135 | + # rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }}) |
| 136 | + # if [ "$rg_exists" = "true" ]; then |
| 137 | + # echo "Resource group exist. Cleaning..." |
| 138 | + # az group delete \ |
| 139 | + # --name ${{ env.RESOURCE_GROUP_NAME }} \ |
| 140 | + # --yes \ |
| 141 | + # --no-wait |
| 142 | + # echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}" |
| 143 | + # else |
| 144 | + # echo "Resource group does not exists." |
| 145 | + # fi |
| 146 | + |
| 147 | + # - name: Wait for resource deletion to complete |
| 148 | + # run: | |
| 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') |
154 | 155 |
|
155 | | - # Convert the comma-separated string into an array |
156 | | - IFS=',' read -r -a resources_to_check <<< "$stripped_keyvaults" |
| 156 | + # # Convert the comma-separated string into an array |
| 157 | + # IFS=',' read -r -a resources_to_check <<< "$stripped_keyvaults" |
157 | 158 |
|
158 | | - # Append new resources to the array |
159 | | - resources_to_check+=("${{ env.SOLUTION_PREFIX }}-openai" "${{ env.SOLUTION_PREFIX }}-cogser") |
| 159 | + # # Append new resources to the array |
| 160 | + # resources_to_check+=("${{ env.SOLUTION_PREFIX }}-openai" "${{ env.SOLUTION_PREFIX }}-cogser") |
160 | 161 |
|
161 | | - echo "List of resources to check: ${resources_to_check[@]}" |
| 162 | + # echo "List of resources to check: ${resources_to_check[@]}" |
162 | 163 |
|
163 | | - # Get the list of resources in YAML format |
164 | | - resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml) |
165 | | -
|
166 | | - # Maximum number of retries |
167 | | - max_retries=3 |
168 | | -
|
169 | | - # Retry intervals in seconds (30, 60, 120) |
170 | | - retry_intervals=(30 60 120) |
171 | | -
|
172 | | - # Retry mechanism to check resources |
173 | | - retries=0 |
174 | | - while true; do |
175 | | - resource_found=false |
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" -ge "$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 |
204 | | -
|
205 | | - - name: Purging the Resources |
206 | | - if: success() |
207 | | - run: | |
208 | | -
|
209 | | - set -e |
210 | | - # Define variables |
211 | | - OPENAI_COMMON_PART="-openai" |
212 | | - openai_name="${{ env.SOLUTION_PREFIX }}${OPENAI_COMMON_PART}" |
213 | | - echo "Azure OpenAI: $openai_name" |
214 | | -
|
215 | | - MULTISERVICE_COMMON_PART="-cogser" |
216 | | - multiservice_account_name="${{ env.SOLUTION_PREFIX }}${MULTISERVICE_COMMON_PART}" |
217 | | - echo "Azure MultiService Account: $multiservice_account_name" |
218 | | -
|
219 | | - # Purge OpenAI Resource |
220 | | - echo "Purging the OpenAI Resource..." |
221 | | - if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/uksouth/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/$openai_name --verbose; then |
222 | | - echo "Failed to purge openai resource: $openai_name" |
223 | | - else |
224 | | - echo "Purged the openai resource: $openai_name" |
225 | | - fi |
| 164 | + # # Get the list of resources in YAML format |
| 165 | + # resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --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 | + # # Retry mechanism to check resources |
| 174 | + # retries=0 |
| 175 | + # while true; do |
| 176 | + # resource_found=false |
| 177 | + |
| 178 | + # # Iterate through the resources to check |
| 179 | + # for resource in "${resources_to_check[@]}"; do |
| 180 | + # echo "Checking resource: $resource" |
| 181 | + # if echo "$resource_list" | grep -q "name: $resource"; then |
| 182 | + # echo "Resource '$resource' exists in the resource group." |
| 183 | + # resource_found=true |
| 184 | + # else |
| 185 | + # echo "Resource '$resource' does not exist in the resource group." |
| 186 | + # fi |
| 187 | + # done |
| 188 | + |
| 189 | + # # If any resource exists, retry |
| 190 | + # if [ "$resource_found" = true ]; then |
| 191 | + # retries=$((retries + 1)) |
| 192 | + # if [ "$retries" -ge "$max_retries" ]; then |
| 193 | + # echo "Maximum retry attempts reached. Exiting." |
| 194 | + # break |
| 195 | + # else |
| 196 | + # # Wait for the appropriate interval for the current retry |
| 197 | + # echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..." |
| 198 | + # sleep ${retry_intervals[$retries-1]} |
| 199 | + # fi |
| 200 | + # else |
| 201 | + # echo "No resources found. Exiting." |
| 202 | + # break |
| 203 | + # fi |
| 204 | + # done |
| 205 | + |
| 206 | + # - name: Purging the Resources |
| 207 | + # if: success() |
| 208 | + # run: | |
| 209 | + |
| 210 | + # set -e |
| 211 | + # # Define variables |
| 212 | + # OPENAI_COMMON_PART="-openai" |
| 213 | + # openai_name="${{ env.SOLUTION_PREFIX }}${OPENAI_COMMON_PART}" |
| 214 | + # echo "Azure OpenAI: $openai_name" |
| 215 | + |
| 216 | + # MULTISERVICE_COMMON_PART="-cogser" |
| 217 | + # multiservice_account_name="${{ env.SOLUTION_PREFIX }}${MULTISERVICE_COMMON_PART}" |
| 218 | + # echo "Azure MultiService Account: $multiservice_account_name" |
| 219 | + |
| 220 | + # # Purge OpenAI Resource |
| 221 | + # echo "Purging the OpenAI Resource..." |
| 222 | + # if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/uksouth/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/$openai_name --verbose; then |
| 223 | + # echo "Failed to purge openai resource: $openai_name" |
| 224 | + # else |
| 225 | + # echo "Purged the openai resource: $openai_name" |
| 226 | + # fi |
226 | 227 |
|
227 | | - # Purge MultiService Account Resource |
228 | | - echo "Purging the MultiService Account Resource..." |
229 | | - if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/uksouth/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/$multiservice_account_name --verbose; then |
230 | | - echo "Failed to purge multiService account resource: $multiservice_account_name" |
231 | | - else |
232 | | - echo "Purged the multiService account resource: $multiservice_account_name" |
233 | | - fi |
234 | | - |
235 | | - # Ensure KEYVAULTS is properly formatted as a comma-separated string |
236 | | - KEYVAULTS="${{ env.KEYVAULTS }}" |
237 | | - |
238 | | - # Remove the surrounding square brackets, if they exist |
239 | | - stripped_keyvaults=$(echo "$KEYVAULTS" | sed 's/\[\|\]//g') |
| 228 | + # # Purge MultiService Account Resource |
| 229 | + # echo "Purging the MultiService Account Resource..." |
| 230 | + # if ! az resource delete --ids /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/providers/Microsoft.CognitiveServices/locations/uksouth/resourceGroups/${{ env.RESOURCE_GROUP_NAME }}/deletedAccounts/$multiservice_account_name --verbose; then |
| 231 | + # echo "Failed to purge multiService account resource: $multiservice_account_name" |
| 232 | + # else |
| 233 | + # echo "Purged the multiService account resource: $multiservice_account_name" |
| 234 | + # fi |
| 235 | + |
| 236 | + # # Ensure KEYVAULTS is properly formatted as a comma-separated string |
| 237 | + # KEYVAULTS="${{ env.KEYVAULTS }}" |
| 238 | + |
| 239 | + # # Remove the surrounding square brackets, if they exist |
| 240 | + # stripped_keyvaults=$(echo "$KEYVAULTS" | sed 's/\[\|\]//g') |
240 | 241 |
|
241 | | - # Convert the comma-separated string into an array |
242 | | - IFS=',' read -r -a keyvault_array <<< "$stripped_keyvaults" |
243 | | - |
244 | | - echo "Using KeyVaults Array..." |
245 | | - for keyvault_name in "${keyvault_array[@]}"; do |
246 | | - echo "Processing KeyVault: $keyvault_name" |
247 | | - # Check if the KeyVault is soft-deleted |
248 | | - deleted_vaults=$(az keyvault list-deleted --query "[?name=='$keyvault_name']" -o json --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}) |
249 | | - |
250 | | - # If the KeyVault is found in the soft-deleted state, purge it |
251 | | - if [ "$(echo "$deleted_vaults" | jq length)" -gt 0 ]; then |
252 | | - echo "KeyVault '$keyvault_name' is soft-deleted. Proceeding to purge..." |
253 | | - az keyvault purge --name "$keyvault_name" --no-wait |
254 | | - else |
255 | | - echo "KeyVault '$keyvault_name' is not soft-deleted. No action taken." |
256 | | - fi |
257 | | - done |
258 | | - |
259 | | - echo "Resource purging completed successfully" |
| 242 | + # # Convert the comma-separated string into an array |
| 243 | + # IFS=',' read -r -a keyvault_array <<< "$stripped_keyvaults" |
| 244 | + |
| 245 | + # echo "Using KeyVaults Array..." |
| 246 | + # for keyvault_name in "${keyvault_array[@]}"; do |
| 247 | + # echo "Processing KeyVault: $keyvault_name" |
| 248 | + # # Check if the KeyVault is soft-deleted |
| 249 | + # deleted_vaults=$(az keyvault list-deleted --query "[?name=='$keyvault_name']" -o json --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}) |
| 250 | + |
| 251 | + # # If the KeyVault is found in the soft-deleted state, purge it |
| 252 | + # if [ "$(echo "$deleted_vaults" | jq length)" -gt 0 ]; then |
| 253 | + # echo "KeyVault '$keyvault_name' is soft-deleted. Proceeding to purge..." |
| 254 | + # az keyvault purge --name "$keyvault_name" --no-wait |
| 255 | + # else |
| 256 | + # echo "KeyVault '$keyvault_name' is not soft-deleted. No action taken." |
| 257 | + # fi |
| 258 | + # done |
| 259 | + |
| 260 | + # echo "Resource purging completed successfully" |
260 | 261 |
|
261 | | - - name: Send Notification on Failure |
262 | | - if: failure() |
263 | | - run: | |
| 262 | + # - name: Send Notification on Failure |
| 263 | + # if: failure() |
| 264 | + # run: | |
264 | 265 |
|
265 | | - RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 266 | + # RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
266 | 267 |
|
267 | | - # Construct the email body |
268 | | - EMAIL_BODY=$(cat <<EOF |
269 | | - { |
270 | | - "body": "<p>Dear Team,</p><p>We would like to inform you that the Client Advisor 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>" |
271 | | - } |
272 | | - EOF |
273 | | - ) |
| 268 | + # # Construct the email body |
| 269 | + # EMAIL_BODY=$(cat <<EOF |
| 270 | + # { |
| 271 | + # "body": "<p>Dear Team,</p><p>We would like to inform you that the Client Advisor 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>" |
| 272 | + # } |
| 273 | + # EOF |
| 274 | + # ) |
274 | 275 |
|
275 | | - # Send the notification |
276 | | - curl -X POST "${{ secrets.LOGIC_APP_URL }}" \ |
277 | | - -H "Content-Type: application/json" \ |
278 | | - -d "$EMAIL_BODY" || echo "Failed to send notification" |
| 276 | + # # Send the notification |
| 277 | + # curl -X POST "${{ secrets.LOGIC_APP_URL }}" \ |
| 278 | + # -H "Content-Type: application/json" \ |
| 279 | + # -d "$EMAIL_BODY" || echo "Failed to send notification" |
0 commit comments