|
1 | 1 | name: Deploy-Test-Cleanup Pipeline |
2 | 2 |
|
3 | 3 | 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: |
15 | 19 |
|
16 | 20 | env: |
17 | 21 | GPT_MIN_CAPACITY: 200 |
|
36 | 40 | run: | |
37 | 41 | az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }} |
38 | 42 |
|
| 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 | + |
39 | 74 | - name: Install Bicep CLI |
40 | 75 | run: az bicep install |
41 | 76 |
|
@@ -363,6 +398,22 @@ jobs: |
363 | 398 | done |
364 | 399 | echo "Resource purging completed successfully" |
365 | 400 |
|
| 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 | +
|
366 | 417 | - name: Logout from Azure |
367 | 418 | if: always() |
368 | 419 | run: | |
|
0 commit comments