Skip to content

Commit

Permalink
testing automation flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant-Microsoft committed Jan 7, 2025
1 parent 606d235 commit b9be077
Showing 1 changed file with 62 additions and 62 deletions.
124 changes: 62 additions & 62 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
TIMESTAMP=$(date +%Y%m%d%H%M%S)
COMMON_PART="ci-biab"
# UNIQUE_RG_NAME="${COMMON_PART}${TIMESTAMP}"
UNIQUE_RG_NAME="psl-biab-manual"
UNIQUE_RG_NAME="psl-biab-manual2"
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
echo "Generated Resource_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
Expand Down Expand Up @@ -171,71 +171,71 @@ jobs:
# fi


# - name: Wait for resource deletion to complete
# run: |
- name: Wait for resource deletion to complete
run: |
# # Add resources to the array
# resources_to_check=("${{ env.OPENAI_RESOURCE_NAME }}")

# echo "List of resources to check: ${resources_to_check[@]}"

# # Maximum number of retries
# max_retries=3

# # Retry intervals in seconds (30, 60, 120)
# retry_intervals=(30 60 120)

# # Retry mechanism to check resources
# retries=0
# while true; do
# resource_found=false

# # Get the list of resources in YAML format again on each retry
# resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml)

# # Iterate through the resources to check
# for resource in "${resources_to_check[@]}"; do
# echo "Checking resource: $resource"
# if echo "$resource_list" | grep -q "name: $resource"; then
# echo "Resource '$resource' exists in the resource group."
# resource_found=true
# else
# echo "Resource '$resource' does not exist in the resource group."
# fi
# done

# # If any resource exists, retry
# if [ "$resource_found" = true ]; then
# retries=$((retries + 1))
# if [ "$retries" -gt "$max_retries" ]; then
# echo "Maximum retry attempts reached. Exiting."
# break
# else
# # Wait for the appropriate interval for the current retry
# echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
# sleep ${retry_intervals[$retries-1]}
# fi
# else
# echo "No resources found. Exiting."
# break
# fi
# done
# Add resources to the array
resources_to_check=("${{ env.OPENAI_RESOURCE_NAME }}")
echo "List of resources to check: ${resources_to_check[@]}"
# Maximum number of retries
max_retries=3
# Retry intervals in seconds (30, 60, 120)
retry_intervals=(30 60 120)
# Retry mechanism to check resources
retries=0
while true; do
resource_found=false
# Get the list of resources in YAML format again on each retry
resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml)
# Iterate through the resources to check
for resource in "${resources_to_check[@]}"; do
echo "Checking resource: $resource"
if echo "$resource_list" | grep -q "name: $resource"; then
echo "Resource '$resource' exists in the resource group."
resource_found=true
else
echo "Resource '$resource' does not exist in the resource group."
fi
done
# If any resource exists, retry
if [ "$resource_found" = true ]; then
retries=$((retries + 1))
if [ "$retries" -gt "$max_retries" ]; then
echo "Maximum retry attempts reached. Exiting."
break
else
# Wait for the appropriate interval for the current retry
echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
sleep ${retry_intervals[$retries-1]}
fi
else
echo "No resources found. Exiting."
break
fi
done
- name: Purging the Resources
if: success()
run: |
# - name: Purging the Resources
# if: success()
# run: |

set -e
echo "Azure OpenAI: ${{ env.OPENAI_RESOURCE_NAME }}"
# set -e
# echo "Azure OpenAI: ${{ env.OPENAI_RESOURCE_NAME }}"

# Purge OpenAI Resource
echo "Purging the OpenAI Resource..."
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
echo "Failed to purge openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
else
echo "Purged the openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
fi
# # Purge OpenAI Resource
# echo "Purging the OpenAI Resource..."
# 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
# echo "Failed to purge openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
# else
# echo "Purged the openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
# fi

echo "Resource purging completed successfully"
# echo "Resource purging completed successfully"

0 comments on commit b9be077

Please sign in to comment.