3434 - name : Validate infra/ parameters
3535 id : validate_infra
3636 continue-on-error : true
37+ env :
38+ ACCELERATOR_NAME : ${{ env.accelerator_name }}
3739 run : |
3840 set +e
39- python infra/scripts/validate_bicep_params.py --dir infra --strict --no-color --json-output infra_results.json 2>&1 | tee infra_output.txt
41+ RUN_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
42+ python infra/scripts/validate_bicep_params.py --dir infra --strict --no-color \
43+ --json-output infra_results.json \
44+ --html-output email_body.html \
45+ --accelerator-name "${ACCELERATOR_NAME}" \
46+ --run-url "${RUN_URL}" 2>&1 | tee infra_output.txt
4047 EXIT_CODE=${PIPESTATUS[0]}
4148 set -e
4249 echo "## Infra Param Validation" >> "$GITHUB_STEP_SUMMARY"
@@ -61,24 +68,25 @@ jobs:
6168 name : bicep-validation-results
6269 path : |
6370 infra_results.json
71+ email_body.html
6472 retention-days : 30
6573
6674 - name : Send schedule notification on failure
6775 if : github.event_name == 'schedule' && steps.result.outputs.status == 'failure'
6876 env :
6977 LOGICAPP_URL : ${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}
70- GITHUB_REPOSITORY : ${{ github.repository }}
71- GITHUB_RUN_ID : ${{ github.run_id }}
7278 ACCELERATOR_NAME : ${{ env.accelerator_name }}
7379 run : |
74- RUN_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
75- INFRA_OUTPUT=$(sed 's/&/\&/g; s/</\</g; s/>/\>/g' infra_output.txt)
80+ if [ -f email_body.html ]; then
81+ EMAIL_BODY=$(cat email_body.html)
82+ else
83+ EMAIL_BODY="<html><body><p>Bicep parameter validation failed but no HTML report was generated. Check workflow logs for details.</p></body></html>"
84+ fi
7685
7786 jq -n \
7887 --arg name "${ACCELERATOR_NAME}" \
79- --arg infra "$INFRA_OUTPUT" \
80- --arg url "$RUN_URL" \
81- '{subject: ("Bicep Parameter Validation Report - " + $name + " - Issues Detected"), body: ("<p>Dear Team,</p><p>The scheduled <strong>Bicep Parameter Validation</strong> for <strong>" + $name + "</strong> has detected parameter mapping errors.</p><p><strong>infra/ Results:</strong></p><pre>" + $infra + "</pre><p><strong>Run URL:</strong> <a href=\"" + $url + "\">" + $url + "</a></p><p>Please fix the parameter mapping issues at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>")}' \
88+ --arg body "$EMAIL_BODY" \
89+ '{subject: ("Bicep Parameter Validation Report - " + $name + " - Issues Detected"), body: $body}' \
8290 | curl -X POST "${LOGICAPP_URL}" \
8391 -H "Content-Type: application/json" \
8492 -d @- || echo "Failed to send notification"
@@ -87,18 +95,18 @@ jobs:
8795 if : github.event_name == 'schedule' && steps.result.outputs.status == 'success'
8896 env :
8997 LOGICAPP_URL : ${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}
90- GITHUB_REPOSITORY : ${{ github.repository }}
91- GITHUB_RUN_ID : ${{ github.run_id }}
9298 ACCELERATOR_NAME : ${{ env.accelerator_name }}
9399 run : |
94- RUN_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
95- INFRA_OUTPUT=$(sed 's/&/\&/g; s/</\</g; s/>/\>/g' infra_output.txt)
100+ if [ -f email_body.html ]; then
101+ EMAIL_BODY=$(cat email_body.html)
102+ else
103+ EMAIL_BODY="<html><body><p>Bicep parameter validation passed but no HTML report was generated (no parameter file pairs found).</p></body></html>"
104+ fi
96105
97106 jq -n \
98107 --arg name "${ACCELERATOR_NAME}" \
99- --arg infra "$INFRA_OUTPUT" \
100- --arg url "$RUN_URL" \
101- '{subject: ("Bicep Parameter Validation Report - " + $name + " - Passed"), body: ("<p>Dear Team,</p><p>The scheduled <strong>Bicep Parameter Validation</strong> for <strong>" + $name + "</strong> has completed successfully. All parameter mappings are valid.</p><p><strong>infra/ Results:</strong></p><pre>" + $infra + "</pre><p><strong>Run URL:</strong> <a href=\"" + $url + "\">" + $url + "</a></p><p>Best regards,<br>Your Automation Team</p>")}' \
108+ --arg body "$EMAIL_BODY" \
109+ '{subject: ("Bicep Parameter Validation Report - " + $name + " - Passed"), body: $body}' \
102110 | curl -X POST "${LOGICAPP_URL}" \
103111 -H "Content-Type: application/json" \
104112 -d @- || echo "Failed to send notification"
0 commit comments