Skip to content

Commit 1726e1d

Browse files
Added Notification Job
1 parent 74b53e1 commit 1726e1d

2 files changed

Lines changed: 167 additions & 93 deletions

File tree

.github/workflows/deploy-Parameterized.yml

Lines changed: 157 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ jobs:
211211
AZURE_LOCATION: ${{ steps.set_region.outputs.AZURE_LOCATION }}
212212
AZURE_ENV_OPENAI_LOCATION: ${{ steps.set_region.outputs.AZURE_ENV_OPENAI_LOCATION }}
213213
IMAGE_TAG: ${{ steps.determine_image_tag.outputs.IMAGE_TAG }}
214+
QUOTA_FAILED: ${{ steps.quota_failure_output.outputs.QUOTA_FAILED }}
214215
env:
215216
# For automatic triggers: force Non-WAF + Non-EXP, for manual dispatch: use inputs
216217
WAF_ENABLED: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.waf_enabled || false) || false }}
@@ -303,21 +304,15 @@ jobs:
303304
fi
304305
305306
306-
- name: Send Notification on Quota Failure
307-
if: env.QUOTA_FAILED == 'true'
308-
run: |
309-
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
310-
EMAIL_BODY=$(cat <<EOF
311-
{
312-
"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>"
313-
}
314-
EOF
315-
)
316307
317-
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
318-
-H "Content-Type: application/json" \
319-
-d "$EMAIL_BODY" || echo "Failed to send notification"
320308
309+
- name: Set Quota Failure Output
310+
id: quota_failure_output
311+
if: env.QUOTA_FAILED == 'true'
312+
run: |
313+
echo "QUOTA_FAILED=true" >> $GITHUB_OUTPUT
314+
echo "Quota check failed - will notify via separate notification job"
315+
321316
- name: Fail Pipeline if Quota Check Fails
322317
if: env.QUOTA_FAILED == 'true'
323318
run: exit 1
@@ -596,37 +591,7 @@ jobs:
596591
az logout
597592
echo "Logged out from Azure."
598593
599-
- name: Send Notification
600-
if: always()
601-
run: |
602-
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
603-
WEBAPP_URL="${{ steps.get_output.outputs.WEBAPP_URL }}"
604-
RESOURCE_GROUP="${{ steps.check_create_rg.outputs.RESOURCE_GROUP_NAME }}"
605-
IMAGE_TAG="${{ steps.determine_image_tag.outputs.IMAGE_TAG }}"
606-
IS_SUCCESS=${{ job.status == 'success' }}
607-
608-
# Construct the email body based on deployment result
609-
if [ "$IS_SUCCESS" = "true" ]; then
610-
EMAIL_BODY=$(cat <<EOF
611-
{
612-
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen deployment process has completed successfully.</p><p><strong>Deployment Details:</strong><br>• Resource Group: ${RESOURCE_GROUP}<br>• Web App URL: <a href=\"${WEBAPP_URL}\">${WEBAPP_URL}</a></p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a></p><p>The application is now ready for use.</p><p>Best regards,<br>Your Automation Team</p>",
613-
"subject": "DocGen Deployment - Success"
614-
}
615-
EOF
616-
)
617-
else
618-
EMAIL_BODY=$(cat <<EOF
619-
{
620-
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen deployment process has encountered an issue and has failed to complete successfully.</p><p><strong>Deployment Details:</strong><br>• Resource Group: ${RESOURCE_GROUP}</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a></p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>",
621-
"subject": "DocGen Deployment - Failure"
622-
}
623-
EOF
624-
)
625-
fi
626-
# Send the notification
627-
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
628-
-H "Content-Type: application/json" \
629-
-d "$EMAIL_BODY" || echo "Failed to send notification"
594+
630595
631596
- name: Generate Deploy Job Summary
632597
if: always()
@@ -781,28 +746,7 @@ jobs:
781746
azd down --purge --force --no-prompt
782747
echo "Deployment deleted successfully."
783748
784-
- name: Send Notification on Failure
785-
if: always() && (failure() || needs.deploy.result == 'failure')
786-
run: |
787-
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
788-
789-
# Get deployment configuration for notification
790-
WAF_STATUS="${{ github.event.inputs.waf_enabled || true }}"
791-
EXP_STATUS="${{ env.EXP || false }}"
792-
CLEANUP_STATUS="${{ github.event.inputs.cleanup_resources || true }}"
793-
794-
# Construct the email body
795-
EMAIL_BODY=$(cat <<EOF
796-
{
797-
"body": "<p>Dear Team,</p><p>We would like to inform you that the document-generation-solution-accelerator Unified Deployment process has encountered an issue and has failed to complete successfully.</p><p><strong>Configuration:</strong><br>- WAF Enabled: ${WAF_STATUS}<br>- EXP: ${EXP_STATUS}<br>- Cleanup: ${CLEANUP_STATUS}</p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a></p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
798-
}
799-
EOF
800-
)
801749
802-
# Send the notification
803-
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
804-
-H "Content-Type: application/json" \
805-
-d "$EMAIL_BODY" || echo "Failed to send notification"
806750
807751
- name: Logout from Azure
808752
if: always()
@@ -841,3 +785,151 @@ jobs:
841785
echo "- Some resources may still exist in Azure" >> $GITHUB_STEP_SUMMARY
842786
echo "- Manual cleanup may be required" >> $GITHUB_STEP_SUMMARY
843787
fi
788+
789+
send-notifications:
790+
# ============================================================================
791+
# NOTIFICATION JOB
792+
# ============================================================================
793+
# Condition: Always runs to send appropriate notifications based on job results
794+
# Sends notifications for:
795+
# 1. Quota check failures (when deploy job fails due to quota issues)
796+
# 2. Deployment failures (when deploy job fails for other reasons)
797+
# 3. Success notifications (when deploy succeeds and e2e tests succeed)
798+
# 4. Test failure notifications (when deploy succeeds but e2e tests fail)
799+
# ============================================================================
800+
if: always()
801+
needs: [docker-build, deploy, e2e-test, cleanup-deployment]
802+
runs-on: ubuntu-latest
803+
steps:
804+
- name: Send Quota Failure Notification
805+
if: needs.deploy.result == 'failure' && needs.deploy.outputs.QUOTA_FAILED == 'true'
806+
run: |
807+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
808+
EMAIL_BODY=$(cat <<EOF
809+
{
810+
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen deployment has failed due to insufficient Azure quota in the requested regions.</p><p><strong>Issue Details:</strong><br>• Quota check failed for GPT and Text Embedding models<br>• Required GPT Capacity: ${{ env.GPT_MIN_CAPACITY }}<br>• Required Text Embedding Capacity: ${{ env.TEXT_EMBEDDING_MIN_CAPACITY }}<br>• Checked Regions: ${{ vars.AZURE_REGIONS }}</p><p><strong>Action Required:</strong><br>• Increase quota limits in Azure portal<br>• Or select a different region with available quota</p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a></p><p>Please resolve the quota issue and retry the deployment.</p><p>Best regards,<br>Your Automation Team</p>",
811+
"subject": "DocGen Pipeline - Quota Check Failed"
812+
}
813+
EOF
814+
)
815+
816+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
817+
-H "Content-Type: application/json" \
818+
-d "$EMAIL_BODY" || echo "Failed to send quota failure notification"
819+
820+
- name: Send Deployment Failure Notification
821+
if: needs.deploy.result == 'failure' && needs.deploy.outputs.QUOTA_FAILED != 'true'
822+
run: |
823+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
824+
RESOURCE_GROUP="${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}"
825+
IMAGE_TAG="${{ needs.deploy.outputs.IMAGE_TAG }}"
826+
827+
EMAIL_BODY=$(cat <<EOF
828+
{
829+
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen deployment process has encountered an issue and has failed to complete successfully.</p><p><strong>Deployment Details:</strong><br>• Resource Group: ${RESOURCE_GROUP}<br>• Docker Image Tag: ${IMAGE_TAG}<br>• WAF Enabled: ${{ env.WAF_ENABLED }}<br>• EXP Enabled: ${{ env.EXP }}<br>• Branch: ${{ env.BRANCH_NAME }}</p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a></p><p>Please investigate the deployment failure at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>",
830+
"subject": "DocGen Deployment - Failed"
831+
}
832+
EOF
833+
)
834+
835+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
836+
-H "Content-Type: application/json" \
837+
-d "$EMAIL_BODY" || echo "Failed to send deployment failure notification"
838+
839+
- name: Send Success Notification
840+
if: needs.deploy.result == 'success' && (needs.e2e-test.result == 'skipped' || needs.e2e-test.outputs.TEST_SUCCESS == 'true')
841+
run: |
842+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
843+
WEBAPP_URL="${{ needs.deploy.outputs.WEBAPP_URL || github.event.inputs.existing_webapp_url }}"
844+
RESOURCE_GROUP="${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}"
845+
IMAGE_TAG="${{ needs.deploy.outputs.IMAGE_TAG }}"
846+
TEST_REPORT_URL="${{ needs.e2e-test.outputs.TEST_REPORT_URL }}"
847+
848+
# Determine test status message
849+
if [ "${{ needs.e2e-test.result }}" = "skipped" ]; then
850+
TEST_STATUS_MSG="• E2E Tests: Skipped (as configured)"
851+
else
852+
TEST_STATUS_MSG="• E2E Tests: ✅ Passed<br>• Test Report: <a href=\"${TEST_REPORT_URL}\">View Report</a>"
853+
fi
854+
855+
EMAIL_BODY=$(cat <<EOF
856+
{
857+
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen deployment and testing process has completed successfully.</p><p><strong>Deployment Details:</strong><br>• Resource Group: ${RESOURCE_GROUP}<br>• Web App URL: <a href=\"${WEBAPP_URL}\">${WEBAPP_URL}</a><br>• Docker Image Tag: ${IMAGE_TAG}<br>${TEST_STATUS_MSG}</p><p><strong>Configuration:</strong><br>• WAF Enabled: ${{ env.WAF_ENABLED }}<br>• EXP Enabled: ${{ env.EXP }}<br>• Branch: ${{ env.BRANCH_NAME }}</p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a></p><p>The application is now ready for use.</p><p>Best regards,<br>Your Automation Team</p>",
858+
"subject": "DocGen Pipeline - Success"
859+
}
860+
EOF
861+
)
862+
863+
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
864+
-H "Content-Type: application/json" \
865+
-d "$EMAIL_BODY" || echo "Failed to send success notification"
866+
867+
- name: Send Test Failure Notification
868+
if: needs.deploy.result == 'success' && needs.e2e-test.result != 'skipped' && needs.e2e-test.outputs.TEST_SUCCESS != 'true'
869+
run: |
870+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
871+
TEST_REPORT_URL="${{ needs.e2e-test.outputs.TEST_REPORT_URL }}"
872+
WEBAPP_URL="${{ needs.deploy.outputs.WEBAPP_URL || github.event.inputs.existing_webapp_url }}"
873+
RESOURCE_GROUP="${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}"
874+
875+
EMAIL_BODY=$(cat <<EOF
876+
{
877+
"body": "<p>Dear Team,</p><p>We would like to inform you that while the DocGen deployment was successful, the E2E test automation process has encountered issues and failed to complete successfully.</p><p><strong>Deployment Details:</strong><br>• Resource Group: ${RESOURCE_GROUP}<br>• Web App URL: <a href=\"${WEBAPP_URL}\">${WEBAPP_URL}</a><br>• Deployment Status: ✅ Success<br>• E2E Tests: ❌ Failed</p><p><strong>Test Details:</strong><br>• Test Report: <a href=\"${TEST_REPORT_URL}\">View Report</a></p><p><strong>Build URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a></p><p>The application has been deployed successfully, but please investigate the test failures to ensure functionality.</p><p>Best regards,<br>Your Automation Team</p>",
878+
"subject": "DocGen Pipeline - Deployment Success, Tests Failed"
879+
}
880+
EOF
881+
)
882+
883+
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}" \
884+
-H "Content-Type: application/json" \
885+
-d "$EMAIL_BODY" || echo "Failed to send test failure notification"
886+
887+
- name: Generate Notification Job Summary
888+
if: always()
889+
run: |
890+
echo "## 📧 Notification Job Summary" >> $GITHUB_STEP_SUMMARY
891+
echo "" >> $GITHUB_STEP_SUMMARY
892+
echo "| Notification Type | Condition | Status | Sent |" >> $GITHUB_STEP_SUMMARY
893+
echo "|------------------|-----------|--------|------|" >> $GITHUB_STEP_SUMMARY
894+
895+
# Check quota failure notification
896+
if [[ "${{ needs.deploy.result }}" == "failure" && "${{ needs.deploy.outputs.QUOTA_FAILED }}" == "true" ]]; then
897+
echo "| **Quota Failure** | Deploy failed due to quota | ❌ Quota Issue | ✅ Sent |" >> $GITHUB_STEP_SUMMARY
898+
else
899+
echo "| **Quota Failure** | Deploy failed due to quota | ✅ No Quota Issues | ⏸️ Not Needed |" >> $GITHUB_STEP_SUMMARY
900+
fi
901+
902+
# Check deployment failure notification
903+
if [[ "${{ needs.deploy.result }}" == "failure" && "${{ needs.deploy.outputs.QUOTA_FAILED }}" != "true" ]]; then
904+
echo "| **Deployment Failure** | Deploy failed (non-quota) | ❌ Deploy Failed | ✅ Sent |" >> $GITHUB_STEP_SUMMARY
905+
else
906+
echo "| **Deployment Failure** | Deploy failed (non-quota) | ✅ No Issues | ⏸️ Not Needed |" >> $GITHUB_STEP_SUMMARY
907+
fi
908+
909+
# Check success notification
910+
SUCCESS_CONDITION="${{ needs.deploy.result == 'success' && (needs.e2e-test.result == 'skipped' || needs.e2e-test.outputs.TEST_SUCCESS == 'true') }}"
911+
if [[ "$SUCCESS_CONDITION" == "true" ]]; then
912+
echo "| **Success** | Deploy success + tests pass/skip | ✅ All Good | ✅ Sent |" >> $GITHUB_STEP_SUMMARY
913+
else
914+
echo "| **Success** | Deploy success + tests pass/skip | ❌ Conditions Not Met | ⏸️ Not Needed |" >> $GITHUB_STEP_SUMMARY
915+
fi
916+
917+
# Check test failure notification
918+
TEST_FAIL_CONDITION="${{ needs.deploy.result == 'success' && needs.e2e-test.result != 'skipped' && needs.e2e-test.outputs.TEST_SUCCESS != 'true' }}"
919+
if [[ "$TEST_FAIL_CONDITION" == "true" ]]; then
920+
echo "| **Test Failure** | Deploy success but tests fail | ❌ Tests Failed | ✅ Sent |" >> $GITHUB_STEP_SUMMARY
921+
else
922+
echo "| **Test Failure** | Deploy success but tests fail | ✅ No Test Issues | ⏸️ Not Needed |" >> $GITHUB_STEP_SUMMARY
923+
fi
924+
925+
echo "" >> $GITHUB_STEP_SUMMARY
926+
echo "### 📋 Pipeline Results Summary" >> $GITHUB_STEP_SUMMARY
927+
echo "- **Deploy Job**: ${{ needs.deploy.result == 'success' && '✅ Success' || needs.deploy.result == 'failure' && '❌ Failed' || '⏸️ Skipped' }}" >> $GITHUB_STEP_SUMMARY
928+
echo "- **E2E Test Job**: ${{ needs.e2e-test.result == 'success' && '✅ Success' || needs.e2e-test.result == 'failure' && '❌ Failed' || '⏸️ Skipped' }}" >> $GITHUB_STEP_SUMMARY
929+
echo "- **Test Results**: ${{ needs.e2e-test.outputs.TEST_SUCCESS == 'true' && '✅ Passed' || needs.e2e-test.outputs.TEST_SUCCESS == 'false' && '❌ Failed' || '⏸️ Not Run' }}" >> $GITHUB_STEP_SUMMARY
930+
echo "- **Quota Status**: ${{ needs.deploy.outputs.QUOTA_FAILED == 'true' && '❌ Quota Failed' || '✅ Quota OK' }}" >> $GITHUB_STEP_SUMMARY
931+
echo "" >> $GITHUB_STEP_SUMMARY
932+
echo "### 🔗 Links" >> $GITHUB_STEP_SUMMARY
933+
echo "- **Pipeline Run**: [View Details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
934+
echo "- **Branch**: ${{ env.BRANCH_NAME }}" >> $GITHUB_STEP_SUMMARY
935+
echo "- **Trigger**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY

.github/workflows/test-automation.yml

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ on:
1111
EMAILNOTIFICATION_LOGICAPP_URL_TA:
1212
required: false
1313
description: "Logic App URL for email notifications"
14+
outputs:
15+
TEST_SUCCESS:
16+
description: "Whether tests passed"
17+
value: ${{ jobs.test.outputs.TEST_SUCCESS }}
18+
TEST_REPORT_URL:
19+
description: "URL to test report artifact"
20+
value: ${{ jobs.test.outputs.TEST_REPORT_URL }}
1421

1522
env:
1623
url: ${{ inputs.DOCGEN_URL }}
@@ -19,6 +26,9 @@ env:
1926
jobs:
2027
test:
2128
runs-on: ubuntu-latest
29+
outputs:
30+
TEST_SUCCESS: ${{ steps.test1.outcome == 'success' || steps.test2.outcome == 'success' || steps.test3.outcome == 'success' }}
31+
TEST_REPORT_URL: ${{ steps.upload_report.outputs.artifact-url }}
2232
steps:
2333
- name: Checkout repository
2434
uses: actions/checkout@v5
@@ -85,35 +95,7 @@ jobs:
8595
name: test-report
8696
path: tests/e2e-test/report/*
8797

88-
- name: Send Notification
89-
if: always()
90-
run: |
91-
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
92-
REPORT_URL=${{ steps.upload_report.outputs.artifact-url }}
93-
IS_SUCCESS=${{ steps.test1.outcome == 'success' || steps.test2.outcome == 'success' || steps.test3.outcome == 'success' }}
94-
# Construct the email body
95-
if [ "$IS_SUCCESS" = "true" ]; then
96-
EMAIL_BODY=$(cat <<EOF
97-
{
98-
"body": "<p>Dear Team,</p><p>We would like to inform you that the ${{ env.accelerator_name }} Test Automation process has completed successfully.</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br></p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p>Best regards,<br>Your Automation Team</p>",
99-
"subject": "${{ env.accelerator_name }} Test Automation - Success"
100-
}
101-
EOF
102-
)
103-
else
104-
EMAIL_BODY=$(cat <<EOF
105-
{
106-
"body": "<p>Dear Team,</p><p>We would like to inform you that the ${{ env.accelerator_name }} Test Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Run URL:</strong> <a href=\"${RUN_URL}\">${RUN_URL}</a><br> ${OUTPUT}</p><p><strong>Test Report:</strong> <a href=\"${REPORT_URL}\">${REPORT_URL}</a></p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>",
107-
"subject": "${{ env.accelerator_name }} Test Automation - Failure"
108-
}
109-
EOF
110-
)
111-
fi
11298

113-
# Send the notification
114-
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}" \
115-
-H "Content-Type: application/json" \
116-
-d "$EMAIL_BODY" || echo "Failed to send notification"
11799

118100
- name: Generate E2E Test Summary
119101
if: always()

0 commit comments

Comments
 (0)