Skip to content

Commit 0d34f2f

Browse files
added quota check
1 parent bec8978 commit 0d34f2f

1 file changed

Lines changed: 62 additions & 11 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
name: Deploy-Test-Cleanup Pipeline
22

33
on:
4-
workflow_run:
5-
workflows: ["Build Docker and Optional Push"]
6-
types:
7-
- completed
8-
branches:
9-
- main
10-
- dev
11-
- demo
12-
schedule:
13-
- cron: '0 5,17 * * *' # Runs at 5:00 AM and 5:00 PM GMT
14-
workflow_dispatch:
4+
push:
5+
branches:
6+
- psl-us-20013
7+
# on:
8+
# workflow_run:
9+
# workflows: ["Build Docker and Optional Push"]
10+
# types:
11+
# - completed
12+
# branches:
13+
# - main
14+
# - dev
15+
# - demo
16+
# schedule:
17+
# - cron: '0 5,17 * * *' # Runs at 5:00 AM and 5:00 PM GMT
18+
# workflow_dispatch:
1519

1620
env:
1721
GPT_MIN_CAPACITY: 200
@@ -36,6 +40,37 @@ jobs:
3640
run: |
3741
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
3842
43+
- name: Run Quota Check
44+
id: quota-check
45+
run: |
46+
chmod +x scripts/checkquota.sh
47+
if ! scripts/checkquota.sh; then
48+
# If quota check fails due to insufficient quota, set the flag
49+
if grep -q "No region with sufficient quota found" scripts/checkquota.sh; then
50+
echo "QUOTA_FAILED=true" >> $GITHUB_ENV
51+
fi
52+
exit 1 # Fail the pipeline if any other failure occurs
53+
fi
54+
55+
- name: Send Notification on Quota Failure
56+
if: env.QUOTA_FAILED == 'true'
57+
run: |
58+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
59+
EMAIL_BODY=$(cat <<EOF
60+
{
61+
"body": "<p>Dear Team,</p><p>The quota check has failed, and the pipeline cannot proceed.</p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a></p><p>Please take necessary action.</p><p>Best regards,<br>Your Automation Team</p>"
62+
}
63+
EOF
64+
)
65+
66+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
67+
-H "Content-Type: application/json" \
68+
-d "$EMAIL_BODY" || echo "Failed to send notification"
69+
70+
- name: Fail Pipeline if Quota Check Fails
71+
if: env.QUOTA_FAILED == 'true'
72+
run: exit 1
73+
3974
- name: Install Bicep CLI
4075
run: az bicep install
4176

@@ -363,6 +398,22 @@ jobs:
363398
done
364399
echo "Resource purging completed successfully"
365400
401+
- name: Send Notification on Failure
402+
if: failure() || needs.deploy.result == 'failure'
403+
run: |
404+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
405+
406+
EMAIL_BODY=$(cat <<EOF
407+
{
408+
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen Deployment Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br></p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
409+
}
410+
EOF
411+
)
412+
413+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
414+
-H "Content-Type: application/json" \
415+
-d "$EMAIL_BODY" || echo "Failed to send notification"
416+
366417
- name: Logout from Azure
367418
if: always()
368419
run: |

0 commit comments

Comments
 (0)