3333 - name : Validate infra/ parameters
3434 id : validate_infra
3535 continue-on-error : true
36+ env :
37+ ACCELERATOR_NAME : ${{ env.accelerator_name }}
3638 run : |
3739 set +e
38- python infra/scripts/validate_bicep_params.py --dir infra --strict --no-color --json-output infra_results.json 2>&1 | tee infra_output.txt
40+ RUN_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
41+ python infra/scripts/validate_bicep_params.py --dir infra --strict --no-color \
42+ --json-output infra_results.json \
43+ --html-output email_body.html \
44+ --accelerator-name "${ACCELERATOR_NAME}" \
45+ --run-url "${RUN_URL}" 2>&1 | tee infra_output.txt
3946 EXIT_CODE=${PIPESTATUS[0]}
4047 set -e
4148 echo "## Infra Param Validation" >> "$GITHUB_STEP_SUMMARY"
@@ -60,44 +67,37 @@ jobs:
6067 name : bicep-validation-results
6168 path : |
6269 infra_results.json
70+ email_body.html
6371 retention-days : 30
6472
6573 - name : Send schedule notification on failure
66- if : github.event_name == 'schedule' && steps.result.outputs.status == 'failure'
74+ if : ( github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && steps.result.outputs.status == 'failure'
6775 env :
6876 LOGICAPP_URL : ${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}
69- GITHUB_REPOSITORY : ${{ github.repository }}
70- GITHUB_RUN_ID : ${{ github.run_id }}
7177 ACCELERATOR_NAME : ${{ env.accelerator_name }}
7278 run : |
73- RUN_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
74- INFRA_OUTPUT=$(sed 's/&/\&/g; s/</\</g; s/>/\>/g' infra_output.txt)
79+ EMAIL_BODY=$(cat email_body.html)
7580
7681 jq -n \
7782 --arg name "${ACCELERATOR_NAME}" \
78- --arg infra "$INFRA_OUTPUT" \
79- --arg url "$RUN_URL" \
80- '{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>")}' \
83+ --arg body "$EMAIL_BODY" \
84+ '{subject: ("Bicep Parameter Validation Report - " + $name + " - Issues Detected"), body: $body}' \
8185 | curl -X POST "${LOGICAPP_URL}" \
8286 -H "Content-Type: application/json" \
8387 -d @- || echo "Failed to send notification"
8488
8589 - name : Send schedule notification on success
86- if : github.event_name == 'schedule' && steps.result.outputs.status == 'success'
90+ if : ( github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && steps.result.outputs.status == 'success'
8791 env :
8892 LOGICAPP_URL : ${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}
89- GITHUB_REPOSITORY : ${{ github.repository }}
90- GITHUB_RUN_ID : ${{ github.run_id }}
9193 ACCELERATOR_NAME : ${{ env.accelerator_name }}
9294 run : |
93- RUN_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
94- INFRA_OUTPUT=$(sed 's/&/\&/g; s/</\</g; s/>/\>/g' infra_output.txt)
95+ EMAIL_BODY=$(cat email_body.html)
9596
9697 jq -n \
9798 --arg name "${ACCELERATOR_NAME}" \
98- --arg infra "$INFRA_OUTPUT" \
99- --arg url "$RUN_URL" \
100- '{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>")}' \
99+ --arg body "$EMAIL_BODY" \
100+ '{subject: ("Bicep Parameter Validation Report - " + $name + " - Passed"), body: $body}' \
101101 | curl -X POST "${LOGICAPP_URL}" \
102102 -H "Content-Type: application/json" \
103103 -d @- || echo "Failed to send notification"
0 commit comments