Skip to content

Commit 066fe30

Browse files
updated the tags and branch
1 parent 70ff4ea commit 066fe30

File tree

6 files changed

+265
-26
lines changed

6 files changed

+265
-26
lines changed

.github/workflows/deploy-v2.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Validate Deployment
1+
name: Validate Deployment v2
22

33
on:
44
workflow_run:
@@ -7,8 +7,7 @@ on:
77
- completed
88
branches:
99
- macae-v2
10-
# - hotfix
11-
# - dev
10+
- dev
1211
schedule:
1312
- cron: "0 11,23 * * *" # Runs at 11:00 AM and 11:00 PM GMT
1413
workflow_dispatch: #Allow manual triggering
@@ -117,8 +116,8 @@ jobs:
117116
run: |
118117
if [[ "${{ env.BRANCH_NAME }}" == "macae-v2" ]]; then
119118
IMAGE_TAG="latest"
120-
# elif [[ "${{ env.BRANCH_NAME }}" == "dev" ]]; then
121-
# IMAGE_TAG="dev"
119+
elif [[ "${{ env.BRANCH_NAME }}" == "dev" ]]; then
120+
IMAGE_TAG="dev"
122121
# elif [[ "${{ env.BRANCH_NAME }}" == "hotfix" ]]; then
123122
# IMAGE_TAG="hotfix"
124123
# else
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
name: Validate WAF Deployment v2
2+
3+
on:
4+
push:
5+
branches:
6+
- macae-v2
7+
schedule:
8+
- cron: "0 11,23 * * *" # Runs at 11:00 AM and 11:00 PM GMT
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v3
16+
17+
- name: Run Quota Check
18+
id: quota-check
19+
run: |
20+
export AZURE_CLIENT_ID=${{ secrets.AZURE_CLIENT_ID }}
21+
export AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}
22+
export AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}
23+
export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}"
24+
export GPT_MIN_CAPACITY="150"
25+
export AZURE_REGIONS="${{ vars.AZURE_REGIONS }}"
26+
27+
chmod +x infra/scripts/checkquota.sh
28+
if ! infra/scripts/checkquota.sh; then
29+
# If quota check fails due to insufficient quota, set the flag
30+
if grep -q "No region with sufficient quota found" infra/scripts/checkquota.sh; then
31+
echo "QUOTA_FAILED=true" >> $GITHUB_ENV
32+
fi
33+
exit 1 # Fail the pipeline if any other failure occurs
34+
fi
35+
36+
- name: Send Notification on Quota Failure
37+
if: env.QUOTA_FAILED == 'true'
38+
run: |
39+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
40+
EMAIL_BODY=$(cat <<EOF
41+
{
42+
"body": "<p>Dear Team,</p><p>The quota check has failed, and the pipeline cannot proceed.</p><p><strong>Build URL:</strong> ${RUN_URL}</p><p>Please take necessary action.</p><p>Best regards,<br>Your Automation Team</p>"
43+
}
44+
EOF
45+
)
46+
47+
curl -X POST "${{ secrets.AUTO_LOGIC_APP_URL }}" \
48+
-H "Content-Type: application/json" \
49+
-d "$EMAIL_BODY" || echo "Failed to send notification"
50+
51+
- name: Fail Pipeline if Quota Check Fails
52+
if: env.QUOTA_FAILED == 'true'
53+
run: exit 1
54+
55+
- name: Set Deployment Region
56+
run: |
57+
echo "Selected Region: $VALID_REGION"
58+
echo "AZURE_LOCATION=$VALID_REGION" >> $GITHUB_ENV
59+
60+
- name: Setup Azure CLI
61+
run: |
62+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
63+
az --version # Verify installation
64+
65+
- name: Login to Azure
66+
run: |
67+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
68+
69+
- name: Install Bicep CLI
70+
run: az bicep install
71+
72+
- name: Generate Resource Group Name
73+
id: generate_rg_name
74+
run: |
75+
echo "Generating a unique resource group name..."
76+
ACCL_NAME="macae" # Account name as specified
77+
SHORT_UUID=$(uuidgen | cut -d'-' -f1)
78+
UNIQUE_RG_NAME="arg-${ACCL_NAME}-${SHORT_UUID}"
79+
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
80+
echo "Generated Resource_GROUP_PREFIX: ${UNIQUE_RG_NAME}"
81+
82+
- name: Check and Create Resource Group
83+
id: check_create_rg
84+
run: |
85+
set -e
86+
echo "Checking if resource group exists..."
87+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
88+
if [ "$rg_exists" = "false" ]; then
89+
echo "Resource group does not exist. Creating..."
90+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location ${{ env.AZURE_LOCATION }} || { echo "Error creating resource group"; exit 1; }
91+
else
92+
echo "Resource group already exists."
93+
fi
94+
95+
- name: Generate Unique Solution Prefix
96+
id: generate_solution_prefix
97+
run: |
98+
COMMON_PART="macae"
99+
TIMESTAMP=$(date +%s)
100+
UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 6)
101+
UNIQUE_SOLUTION_PREFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
102+
echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
103+
104+
- name: Deploy Bicep Template
105+
id: deploy
106+
run: |
107+
set -e
108+
az deployment group create \
109+
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
110+
--template-file infra/main.bicep \
111+
--parameters \
112+
solutionName=${{ env.SOLUTION_PREFIX }} \
113+
location="${{ env.AZURE_LOCATION }}" \
114+
azureAiServiceLocation='${{ env.AZURE_LOCATION }}' \
115+
gptModelCapacity=5 \
116+
enableTelemetry=true \
117+
enableMonitoring=true \
118+
enablePrivateNetworking=true \
119+
enableScalability=true \
120+
createdBy="Pipeline" \
121+
122+
123+
- name: Send Notification on Failure
124+
if: failure()
125+
run: |
126+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
127+
128+
# Construct the email body
129+
EMAIL_BODY=$(cat <<EOF
130+
{
131+
"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>"
132+
}
133+
EOF
134+
)
135+
136+
# Send the notification
137+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
138+
-H "Content-Type: application/json" \
139+
-d "$EMAIL_BODY" || echo "Failed to send notification"
140+
141+
- name: Get OpenAI Resource from Resource Group
142+
id: get_openai_resource
143+
run: |
144+
145+
146+
set -e
147+
echo "Fetching OpenAI resource from resource group ${{ env.RESOURCE_GROUP_NAME }}..."
148+
149+
# Run the az resource list command to get the OpenAI resource name
150+
openai_resource_name=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --resource-type "Microsoft.CognitiveServices/accounts" --query "[0].name" -o tsv)
151+
152+
if [ -z "$openai_resource_name" ]; then
153+
echo "No OpenAI resource found in resource group ${{ env.RESOURCE_GROUP_NAME }}."
154+
exit 1
155+
else
156+
echo "OPENAI_RESOURCE_NAME=${openai_resource_name}" >> $GITHUB_ENV
157+
echo "OpenAI resource name: ${openai_resource_name}"
158+
fi
159+
160+
- name: Delete Bicep Deployment
161+
if: always()
162+
run: |
163+
set -e
164+
echo "Checking if resource group exists..."
165+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
166+
if [ "$rg_exists" = "true" ]; then
167+
echo "Resource group exist. Cleaning..."
168+
az group delete \
169+
--name ${{ env.RESOURCE_GROUP_NAME }} \
170+
--yes \
171+
--no-wait
172+
echo "Resource group deleted... ${{ env.RESOURCE_GROUP_NAME }}"
173+
else
174+
echo "Resource group does not exists."
175+
fi
176+
177+
- name: Wait for resource deletion to complete
178+
run: |
179+
180+
181+
# Add resources to the array
182+
resources_to_check=("${{ env.OPENAI_RESOURCE_NAME }}")
183+
184+
echo "List of resources to check: ${resources_to_check[@]}"
185+
186+
# Maximum number of retries
187+
max_retries=3
188+
189+
# Retry intervals in seconds (30, 60, 120)
190+
retry_intervals=(30 60 120)
191+
192+
# Retry mechanism to check resources
193+
retries=0
194+
while true; do
195+
resource_found=false
196+
197+
# Get the list of resources in YAML format again on each retry
198+
resource_list=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --output yaml)
199+
200+
# Iterate through the resources to check
201+
for resource in "${resources_to_check[@]}"; do
202+
echo "Checking resource: $resource"
203+
if echo "$resource_list" | grep -q "name: $resource"; then
204+
echo "Resource '$resource' exists in the resource group."
205+
resource_found=true
206+
else
207+
echo "Resource '$resource' does not exist in the resource group."
208+
fi
209+
done
210+
211+
# If any resource exists, retry
212+
if [ "$resource_found" = true ]; then
213+
retries=$((retries + 1))
214+
if [ "$retries" -gt "$max_retries" ]; then
215+
echo "Maximum retry attempts reached. Exiting."
216+
break
217+
else
218+
# Wait for the appropriate interval for the current retry
219+
echo "Waiting for ${retry_intervals[$retries-1]} seconds before retrying..."
220+
sleep ${retry_intervals[$retries-1]}
221+
fi
222+
else
223+
echo "No resources found. Exiting."
224+
break
225+
fi
226+
done
227+
228+
- name: Purging the Resources
229+
if: always()
230+
run: |
231+
232+
set -e
233+
echo "Azure OpenAI: ${{ env.OPENAI_RESOURCE_NAME }}"
234+
235+
# Purge OpenAI Resource
236+
echo "Purging the OpenAI Resource..."
237+
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
238+
echo "Failed to purge openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
239+
else
240+
echo "Purged the openai resource: ${{ env.OPENAI_RESOURCE_NAME }}"
241+
fi
242+
243+
echo "Resource purging completed successfully"

.github/workflows/deploy-waf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Validate WAF Deployment
1+
name: Validate WAF Deployment v3
22

33
on:
44
push:

.github/workflows/deploy.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Validate Deployment
1+
name: Validate Deployment v3
22

33
on:
44
workflow_run:
@@ -9,7 +9,6 @@ on:
99
- main
1010
- dev-v3
1111
- hotfix
12-
- dev
1312
schedule:
1413
- cron: "0 11,23 * * *" # Runs at 11:00 AM and 11:00 PM GMT
1514
workflow_dispatch: #Allow manual triggering
@@ -118,8 +117,6 @@ jobs:
118117
run: |
119118
if [[ "${{ env.BRANCH_NAME }}" == "main" ]]; then
120119
IMAGE_TAG="latest_v3"
121-
elif [[ "${{ env.BRANCH_NAME }}" == "dev" ]]; then
122-
IMAGE_TAG="dev_v3"
123120
elif [[ "${{ env.BRANCH_NAME }}" == "dev-v3" ]]; then
124121
IMAGE_TAG="dev_v3"
125122
elif [[ "${{ env.BRANCH_NAME }}" == "hotfix" ]]; then

.github/workflows/docker-build-and-push-v2.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: Build Docker and Optional Push
1+
name: Build Docker and Optional Push v2
22

33
on:
44
push:
55
branches:
66
# - main
7-
# - dev
7+
- dev
88
# - dev-v3
99
- macae-v2
10-
# - demo
10+
- demo
1111
# - hotfix
1212
pull_request:
1313
types:
@@ -17,10 +17,10 @@ on:
1717
- synchronize
1818
branches:
1919
# - main
20-
# - dev
20+
- dev
2121
# - dev-v3
2222
- macae-v2
23-
# - demo
23+
- demo
2424
# - hotfix
2525
workflow_dispatch:
2626

@@ -36,7 +36,7 @@ jobs:
3636
uses: docker/setup-buildx-action@v1
3737

3838
- name: Log in to Azure Container Registry
39-
if: ${{ github.ref_name == 'macae-v2' }}
39+
if: ${{ github.ref_name == 'macae-v2' || github.ref_name == 'dev' || github.ref_name == 'demo'}}
4040
uses: azure/docker-login@v2
4141
with:
4242
login-server: ${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}
@@ -58,6 +58,10 @@ jobs:
5858
5959
if [[ "${{ github.ref }}" == "refs/heads/macae-v2" ]]; then
6060
echo "TAG=latest" >> $GITHUB_ENV
61+
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
62+
echo "TAG=dev" >> $GITHUB_ENV
63+
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
64+
echo "TAG=demo" >> $GITHUB_ENV
6165
else
6266
echo "TAG=pullrequest-ignore" >> $GITHUB_ENV
6367
fi

.github/workflows/docker-build-and-push.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
name: Build Docker and Optional Push
1+
name: Build Docker and Optional Push v3
22

33
on:
44
push:
55
branches:
66
- main
7-
- dev
87
- dev-v3
9-
- demo
8+
- demo-v3
109
- hotfix
1110
pull_request:
1211
types:
@@ -16,9 +15,8 @@ on:
1615
- synchronize
1716
branches:
1817
- main
19-
- dev
2018
- dev-v3
21-
- demo
19+
- demo-v3
2220
- hotfix
2321
workflow_dispatch:
2422

@@ -34,7 +32,7 @@ jobs:
3432
uses: docker/setup-buildx-action@v1
3533

3634
- name: Log in to Azure Container Registry
37-
if: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'dev-v3'|| github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
35+
if: ${{ github.ref_name == 'main' || github.ref_name == 'dev-v3'|| github.ref_name == 'demo-v3' || github.ref_name == 'hotfix' }}
3836
uses: azure/docker-login@v2
3937
with:
4038
login-server: ${{ secrets.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io' }}
@@ -55,12 +53,10 @@ jobs:
5553
run: |
5654
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
5755
echo "TAG=latest_v3" >> $GITHUB_ENV
58-
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
59-
echo "TAG=dev_v3" >> $GITHUB_ENV
6056
elif [[ "${{ github.ref }}" == "refs/heads/dev-v3" ]]; then
6157
echo "TAG=dev_v3" >> $GITHUB_ENV
62-
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
63-
echo "TAG=demo" >> $GITHUB_ENV
58+
elif [[ "${{ github.ref }}" == "refs/heads/demo-v3" ]]; then
59+
echo "TAG=demo_v3" >> $GITHUB_ENV
6460
elif [[ "${{ github.ref }}" == "refs/heads/hotfix" ]]; then
6561
echo "TAG=hotfix" >> $GITHUB_ENV
6662
else

0 commit comments

Comments
 (0)