1919 cleanup_resources :
2020 description : ' Cleanup deployed resources'
2121 required : false
22- default : true
22+ default : false
2323 type : boolean
24- schedule :
25- - cron : " 0 6,18 * * *" # Runs at 6:00 AM and 6:00 PM GMT
26-
2724env :
2825 GPT_MIN_CAPACITY : 150
2926 TEXT_EMBEDDING_MIN_CAPACITY : 80
@@ -41,14 +38,40 @@ jobs:
4138 ENV_NAME : ${{ steps.generate_env_name.outputs.ENV_NAME }}
4239 AZURE_LOCATION : ${{ steps.set_region.outputs.AZURE_LOCATION }}
4340 env :
44- WAF_ENABLED : ${{ github.event.inputs.waf_enabled || true }}
41+ WAF_ENABLED : ${{ github.event.inputs.waf_enabled || false }}
4542 EXP : ${{ github.event.inputs.EXP || false }}
4643 CLEANUP_RESOURCES : ${{ github.event.inputs.cleanup_resources || true }}
4744
4845 steps :
4946 - name : Checkout Code
5047 uses : actions/checkout@v4
5148
49+ - name : Debug - WAF/EXP/Cleanup Parameters
50+ run : |
51+ echo "=== DEBUGGING: WAF/EXP/Cleanup Parameters ==="
52+ echo "Event type: ${{ github.event_name }}"
53+ echo "Branch: ${{ github.ref_name }}"
54+ echo ""
55+ echo "Raw GitHub Event Inputs:"
56+ echo " github.event.inputs.waf_enabled: '${{ github.event.inputs.waf_enabled }}'"
57+ echo " github.event.inputs.EXP: '${{ github.event.inputs.EXP }}'"
58+ echo " github.event.inputs.cleanup_resources: '${{ github.event.inputs.cleanup_resources }}'"
59+ echo ""
60+ echo "Global Environment Variables (with defaults):"
61+ echo " WAF_ENABLED (global): '${{ env.WAF_ENABLED }}'"
62+ echo " EXP (global): '${{ env.EXP }}'"
63+ echo " CLEANUP_RESOURCES (global): '${{ env.CLEANUP_RESOURCES }}'"
64+ echo ""
65+ echo "Job-level Environment Variables (with different defaults):"
66+ echo " WAF_ENABLED (job): '${{ env.WAF_ENABLED }}' (should be true for push events)"
67+ echo " EXP (job): '${{ env.EXP }}' (should be false)"
68+ echo " CLEANUP_RESOURCES (job): '${{ env.CLEANUP_RESOURCES }}' (should be true)"
69+ echo ""
70+ echo "Logic Evaluation Tests:"
71+ echo " WAF test [[ '${{ env.WAF_ENABLED }}' == 'true' ]]: $(if [[ '${{ env.WAF_ENABLED }}' == 'true' ]]; then echo 'TRUE - WAF WILL BE ENABLED'; else echo 'FALSE - WAF WILL BE DISABLED'; fi)"
72+ echo " EXP test [[ '${{ env.EXP }}' == 'true' ]]: $(if [[ '${{ env.EXP }}' == 'true' ]]; then echo 'TRUE - EXP WILL BE ENABLED'; else echo 'FALSE - EXP WILL BE DISABLED'; fi)"
73+ echo "=== END DEBUG SECTION ==="
74+
5275 - name : Setup Azure CLI
5376 run : |
5477 curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
@@ -69,23 +92,30 @@ jobs:
6992 if ! scripts/checkquota.sh; then
7093 # If quota check fails due to insufficient quota, set the flag
7194 if grep -q "No region with sufficient quota found" scripts/checkquota.sh; then
72- echo "quota_failed=true" >> $GITHUB_OUTPUT
95+ echo "QUOTA_FAILED=true" >> $GITHUB_ENV
96+ fi
97+ exit 1 # Fail the pipeline if any other failure occurs
98+ fi
7399
74- # Send notification
75- RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
76- EMAIL_BODY=$(cat <<EOF
100+
101+ - name : Send Notification on Quota Failure
102+ if : env.QUOTA_FAILED == 'true'
103+ run : |
104+ RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
105+ EMAIL_BODY=$(cat <<EOF
77106 {
78107 "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>"
79108 }
80109 EOF
81- )
110+ )
82111
83- curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
84- -H "Content-Type: application/json" \
85- -d "$EMAIL_BODY" || echo "Failed to send notification"
86- fi
87- exit 1 # Fail the pipeline if any other failure occurs
88- fi
112+ curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
113+ -H "Content-Type: application/json" \
114+ -d "$EMAIL_BODY" || echo "Failed to send notification"
115+
116+ - name : Fail Pipeline if Quota Check Fails
117+ if : env.QUOTA_FAILED == 'true'
118+ run : exit 1
89119
90120 - name : Set Deployment Region
91121 id : set_region
@@ -152,22 +182,10 @@ jobs:
152182 id : determine_tag
153183 run : |
154184 BRANCH=${{ github.ref_name }}
155- WAF_MODE="${{ env.WAF_ENABLED }}"
156- if [[ "$BRANCH" == "main" ]]; then
157- if [[ "$WAF_MODE" == "true" ]]; then
158- TAG="latest_waf"
159- else
160- TAG="latest_Non-waf"
161- fi
185+ if [[ "$BRANCH" == "main" ]]; then TAG="latest_waf"
162186 elif [[ "$BRANCH" == "dev" ]]; then TAG="dev"
163187 elif [[ "$BRANCH" == "demo" ]]; then TAG="demo"
164- else
165- if [[ "$WAF_MODE" == "true" ]]; then
166- TAG="latest_waf"
167- else
168- TAG="latest_Non-waf"
169- fi
170- fi
188+ else TAG="latest_waf"; fi
171189 echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV
172190 echo "Image Tag: $TAG"
173191
@@ -182,14 +200,25 @@ jobs:
182200 echo "Generated Environment Name: ${UNIQUE_ENV_NAME}"
183201 echo "ENV_NAME=${UNIQUE_ENV_NAME}" >> $GITHUB_OUTPUT
184202
203+ - name : Debug - WAF Configuration Decision
204+ run : |
205+ echo "=== DEBUGGING: WAF Configuration Decision ==="
206+ echo "WAF_ENABLED value: '${{ env.WAF_ENABLED }}'"
207+ if [[ "${{ env.WAF_ENABLED }}" == "true" ]]; then
208+ echo "✅ DECISION: WAF ENABLED - Will use main.waf.parameters.json"
209+ else
210+ echo "❌ DECISION: WAF DISABLED - Will use default main.parameters.json"
211+ fi
212+ echo "=== END DEBUG SECTION ==="
213+
185214 - name : Configure Parameters Based on WAF Setting
186215 run : |
187216 if [[ "${{ env.WAF_ENABLED }}" == "true" ]]; then
188- echo "Configuring WAF deployment - copying main.waf.parameters.json to main.parameters.json..."
217+ echo "🔧 Configuring WAF deployment - copying main.waf.parameters.json to main.parameters.json..."
189218 cp infra/main.waf.parameters.json infra/main.parameters.json
190- echo "Successfully copied WAF parameters to main parameters file"
219+ echo "✅ Successfully copied WAF parameters to main parameters file"
191220 else
192- echo "Configuring Non-WAF deployment - using default main.parameters.json..."
221+ echo "🔧 Configuring Non-WAF deployment - using default main.parameters.json..."
193222 # Ensure we have the original parameters file if it was overwritten
194223 if [[ -f infra/main.waf.parameters.json ]] && [[ ! -f infra/main.parameters.json.backup ]]; then
195224 echo "Backing up original parameters file..."
@@ -223,12 +252,18 @@ jobs:
223252 azd env set AZURE_ENV_OPENAI_LOCATION="$AZURE_LOCATION"
224253 azd env set AZURE_RESOURCE_GROUP="$RESOURCE_GROUP_NAME"
225254
226- # Set EXP parameters if enabled
255+ # Debug and Set EXP parameters if enabled
256+ echo "=== DEBUGGING: EXP Configuration ==="
257+ echo "EXP value: '${{ env.EXP }}'"
227258 if [[ "${{ env.EXP }}" == "true" ]]; then
228- echo "Setting EXP parameters..."
259+ echo "✅ EXP ENABLED - Setting EXP parameters..."
229260 azd env set AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID="${{ secrets.EXP_LOG_ANALYTICS_WORKSPACE_ID }}"
230261 azd env set AZURE_EXISTING_AI_PROJECT_RESOURCE_ID="${{ secrets.EXP_AI_PROJECT_RESOURCE_ID }}"
262+ echo "✅ EXP parameters configured successfully"
263+ else
264+ echo "❌ EXP DISABLED - Skipping EXP parameters"
231265 fi
266+ echo "=== END DEBUG SECTION ==="
232267
233268 # Deploy using azd up
234269 azd up --no-prompt
@@ -325,6 +360,32 @@ jobs:
325360 AZURE_LOCATION : ${{ needs.deploy.outputs.AZURE_LOCATION }}
326361 ENV_NAME : ${{ needs.deploy.outputs.ENV_NAME }}
327362 steps :
363+ - name : Debug - Cleanup Job Conditions
364+ run : |
365+ echo "=== DEBUGGING: Cleanup Job Execution Logic ==="
366+ echo "Event type: ${{ github.event_name }}"
367+ echo ""
368+ echo "Cleanup Input Analysis:"
369+ echo " github.event.inputs.cleanup_resources: '${{ github.event.inputs.cleanup_resources }}'"
370+ echo " Global CLEANUP_RESOURCES env: '${{ env.CLEANUP_RESOURCES }}'"
371+ echo ""
372+ echo "Job Execution Conditions:"
373+ echo " always(): true (this job will attempt to run)"
374+ echo " needs.deploy.outputs.RESOURCE_GROUP_NAME != '': ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME != '' }}"
375+ echo " Resource group name: '${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}'"
376+ echo ""
377+ echo "Cleanup Logic Evaluation:"
378+ echo " github.event.inputs.cleanup_resources == true: ${{ github.event.inputs.cleanup_resources == true }}"
379+ echo " github.event.inputs.cleanup_resources == null: ${{ github.event.inputs.cleanup_resources == null }}"
380+ echo " Combined condition result: ${{ github.event.inputs.cleanup_resources == true || github.event.inputs.cleanup_resources == null }}"
381+ echo ""
382+ echo "Job Results:"
383+ echo " Deploy job result: ${{ needs.deploy.result }}"
384+ echo " E2E test job result: ${{ needs.e2e-test.result }}"
385+ echo ""
386+ echo "DECISION: $(if [[ '${{ github.event.inputs.cleanup_resources == true || github.event.inputs.cleanup_resources == null }}' == 'true' ]]; then echo '✅ CLEANUP WILL PROCEED'; else echo '❌ CLEANUP WILL BE SKIPPED'; fi)"
387+ echo "=== END DEBUG SECTION ==="
388+
328389 - name : Checkout Code
329390 uses : actions/checkout@v4
330391
0 commit comments