Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .github/workflows/validate-bicep-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Validate Bicep Parameters

permissions:
contents: read

on:
schedule:
- cron: '30 6 * * 3' # Wednesday 12:00 PM IST (6:30 AM UTC)
pull_request:
branches:
- main
- dev
paths:
- 'infra/**/*.bicep'
- 'infra/**/*.parameters.json'
workflow_dispatch:
push:
branches:
- hb-psl-38859

Comment on lines +16 to +20
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow includes a push trigger limited to the feature branch hb-psl-38859, which doesn’t match the PR description (schedule/PR/manual) and will likely be stale after merge. Recommend removing this push trigger (or switching it to the intended long-lived branches) so the workflow behavior is consistent and maintainable.

Copilot uses AI. Check for mistakes.
env:
accelerator_name: "Content Processing"

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Validate infra/ parameters
id: validate_infra
continue-on-error: true
run: |
python infra/scripts/validate_bicep_params.py --dir infra --strict --no-color --json-output infra_results.json 2>&1 | tee infra_output.txt
EXIT_CODE=${PIPESTATUS[0]}
echo "## Infra Param Validation" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
cat infra_output.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
exit $EXIT_CODE

- name: Set overall result
id: result
run: |
if [[ "${{ steps.validate_infra.outcome }}" == "failure" ]]; then
echo "status=failure" >> "$GITHUB_OUTPUT"
else
echo "status=success" >> "$GITHUB_OUTPUT"
fi

- name: Upload validation results
if: always()
uses: actions/upload-artifact@v4
with:
name: bicep-validation-results
path: |
infra_results.json
retention-days: 30

- name: Send schedule notification on failure
if: steps.result.outputs.status == 'failure'
env:
LOGICAPP_URL: ${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}
ACCELERATOR_NAME: ${{ env.accelerator_name }}
run: |
RUN_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
INFRA_OUTPUT=$(sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g' infra_output.txt)

jq -n \
--arg name "${ACCELERATOR_NAME}" \
--arg infra "$INFRA_OUTPUT" \
--arg url "$RUN_URL" \
'{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>")}' \
| curl -X POST "${LOGICAPP_URL}" \
-H "Content-Type: application/json" \
-d @- || echo "Failed to send notification"

- name: Send schedule notification on success
if: steps.result.outputs.status == 'success'
env:
Comment on lines +66 to +88
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The email notification steps run for all event types (pull_request, workflow_dispatch, and schedule) whenever validation succeeds/fails. This can create noise on PRs and can also invoke an external endpoint with repository secrets in PR contexts. If notifications are intended only for scheduled runs (as the step names/PR description suggest), gate these steps with github.event_name == 'schedule' (and optionally keep artifacts/step summary for PRs).

Copilot uses AI. Check for mistakes.
LOGICAPP_URL: ${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}
ACCELERATOR_NAME: ${{ env.accelerator_name }}
run: |
RUN_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
INFRA_OUTPUT=$(sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g' infra_output.txt)

jq -n \
--arg name "${ACCELERATOR_NAME}" \
--arg infra "$INFRA_OUTPUT" \
--arg url "$RUN_URL" \
'{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>")}' \
| curl -X POST "${LOGICAPP_URL}" \
-H "Content-Type: application/json" \
-d @- || echo "Failed to send notification"

- name: Fail if errors found
if: steps.result.outputs.status == 'failure'
run: exit 1
Loading
Loading