Skip to content

Commit 9314c1f

Browse files
Merge pull request #521 from Rafi-Microsoft/main
feat: Added Deployment v2 pipeline
2 parents e886536 + eb45753 commit 9314c1f

13 files changed

Lines changed: 1474 additions & 49 deletions

.github/workflows/deploy-linux.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Deploy-Test-Cleanup (v2)
2+
on:
3+
push:
4+
branches:
5+
- main # Adjust this to the branch you want to trigger the deployment on
6+
- dev
7+
- demo
8+
schedule:
9+
- cron: "0 10,22 * * *" # Runs at 10:00 AM and 10:00 PM UTC
10+
11+
workflow_dispatch:
12+
inputs:
13+
azure_location:
14+
description: 'Azure Location For Deployment'
15+
required: false
16+
default: 'australiaeast'
17+
type: choice
18+
options:
19+
- 'australiaeast'
20+
- 'centralus'
21+
- 'eastasia'
22+
- 'eastus2'
23+
- 'japaneast'
24+
- 'northeurope'
25+
- 'southeastasia'
26+
- 'uksouth'
27+
resource_group_name:
28+
description: 'Resource Group Name (Optional)'
29+
required: false
30+
default: ''
31+
type: string
32+
33+
waf_enabled:
34+
description: 'Enable WAF'
35+
required: false
36+
default: false
37+
type: boolean
38+
EXP:
39+
description: 'Enable EXP'
40+
required: false
41+
default: false
42+
type: boolean
43+
44+
cleanup_resources:
45+
description: 'Cleanup Deployed Resources'
46+
required: false
47+
default: false
48+
type: boolean
49+
50+
run_e2e_tests:
51+
description: 'Run End-to-End Tests'
52+
required: false
53+
default: 'GoldenPath-Testing'
54+
type: choice
55+
options:
56+
- 'GoldenPath-Testing'
57+
- 'Smoke-Testing'
58+
- 'None'
59+
60+
AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID:
61+
description: 'Log Analytics Workspace ID (Optional)'
62+
required: false
63+
default: ''
64+
type: string
65+
existing_webapp_url:
66+
description: 'Existing WebApp URL (Skips Deployment)'
67+
required: false
68+
default: ''
69+
type: string
70+
71+
jobs:
72+
Run:
73+
uses: ./.github/workflows/deploy-orchestrator.yml
74+
with:
75+
azure_location: ${{ github.event.inputs.azure_location || 'australiaeast' }}
76+
resource_group_name: ${{ github.event.inputs.resource_group_name || '' }}
77+
waf_enabled: ${{ github.event.inputs.waf_enabled == 'true' }}
78+
EXP: ${{ github.event.inputs.EXP == 'true' }}
79+
cleanup_resources: ${{ github.event.inputs.cleanup_resources == 'true' }}
80+
run_e2e_tests: ${{ github.event.inputs.run_e2e_tests || 'GoldenPath-Testing' }}
81+
AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID: ${{ github.event.inputs.AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID || '' }}
82+
existing_webapp_url: ${{ github.event.inputs.existing_webapp_url || '' }}
83+
trigger_type: ${{ github.event_name }}
84+
secrets: inherit
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Deployment orchestrator
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
azure_location:
7+
description: 'Azure Location For Deployment'
8+
required: false
9+
default: 'australiaeast'
10+
type: string
11+
resource_group_name:
12+
description: 'Resource Group Name (Optional)'
13+
required: false
14+
default: ''
15+
type: string
16+
waf_enabled:
17+
description: 'Enable WAF'
18+
required: false
19+
default: false
20+
type: boolean
21+
EXP:
22+
description: 'Enable EXP'
23+
required: false
24+
default: false
25+
type: boolean
26+
cleanup_resources:
27+
description: 'Cleanup Deployed Resources'
28+
required: false
29+
default: false
30+
type: boolean
31+
run_e2e_tests:
32+
description: 'Run End-to-End Tests'
33+
required: false
34+
default: 'GoldenPath-Testing'
35+
type: string
36+
AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID:
37+
description: 'Log Analytics Workspace ID (Optional)'
38+
required: false
39+
default: ''
40+
type: string
41+
existing_webapp_url:
42+
description: 'Existing Container WebApp URL (Skips Deployment)'
43+
required: false
44+
default: ''
45+
type: string
46+
trigger_type:
47+
description: 'Trigger type (workflow_dispatch, pull_request, schedule)'
48+
required: true
49+
type: string
50+
51+
env:
52+
AZURE_DEV_COLLECT_TELEMETRY: ${{ vars.AZURE_DEV_COLLECT_TELEMETRY }}
53+
54+
jobs:
55+
deploy:
56+
if: "!cancelled() && (inputs.trigger_type != 'workflow_dispatch' || inputs.existing_webapp_url == '' || inputs.existing_webapp_url == null)"
57+
uses: ./.github/workflows/job-deploy.yml
58+
with:
59+
trigger_type: ${{ inputs.trigger_type }}
60+
azure_location: ${{ inputs.azure_location }}
61+
resource_group_name: ${{ inputs.resource_group_name }}
62+
waf_enabled: ${{ inputs.waf_enabled }}
63+
EXP: ${{ inputs.EXP }}
64+
existing_webapp_url: ${{ inputs.existing_webapp_url }}
65+
AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID: ${{ inputs.AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID }}
66+
run_e2e_tests: ${{ inputs.run_e2e_tests }}
67+
cleanup_resources: ${{ inputs.cleanup_resources }}
68+
secrets: inherit
69+
70+
e2e-test:
71+
if: "!cancelled() && ((needs.deploy.outputs.WEB_APPURL != '' && needs.deploy.outputs.WEB_APPURL != null) || (inputs.existing_webapp_url != '' && inputs.existing_webapp_url != null)) && (inputs.trigger_type != 'workflow_dispatch' || (inputs.run_e2e_tests != 'None' && inputs.run_e2e_tests != '' && inputs.run_e2e_tests != null))"
72+
needs: [deploy]
73+
uses: ./.github/workflows/test-automation-v2.yml
74+
with:
75+
TEST_URL: ${{ needs.deploy.outputs.WEB_APPURL || inputs.existing_webapp_url }}
76+
TEST_SUITE: ${{ inputs.trigger_type == 'workflow_dispatch' && inputs.run_e2e_tests || 'GoldenPath-Testing' }}
77+
secrets: inherit
78+
79+
send-notification:
80+
if: "!cancelled()"
81+
needs: [deploy, e2e-test]
82+
uses: ./.github/workflows/job-send-notification.yml
83+
with:
84+
trigger_type: ${{ inputs.trigger_type }}
85+
waf_enabled: ${{ inputs.waf_enabled }}
86+
EXP: ${{ inputs.EXP }}
87+
run_e2e_tests: ${{ inputs.run_e2e_tests }}
88+
existing_webapp_url: ${{ inputs.existing_webapp_url }}
89+
deploy_result: ${{ needs.deploy.result }}
90+
e2e_test_result: ${{ needs.e2e-test.result }}
91+
WEB_APPURL: ${{ needs.deploy.outputs.WEB_APPURL || inputs.existing_webapp_url }}
92+
RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
93+
QUOTA_FAILED: ${{ needs.deploy.outputs.QUOTA_FAILED }}
94+
TEST_SUCCESS: ${{ needs.e2e-test.outputs.TEST_SUCCESS }}
95+
TEST_REPORT_URL: ${{ needs.e2e-test.outputs.TEST_REPORT_URL }}
96+
secrets: inherit
97+
98+
cleanup-deployment:
99+
if: "!cancelled() && needs.deploy.result == 'success' && needs.deploy.outputs.RESOURCE_GROUP_NAME != '' && inputs.existing_webapp_url == '' && (inputs.trigger_type != 'workflow_dispatch' || inputs.cleanup_resources)"
100+
needs: [deploy, e2e-test]
101+
uses: ./.github/workflows/job-cleanup-deployment.yml
102+
with:
103+
trigger_type: ${{ inputs.trigger_type }}
104+
cleanup_resources: ${{ inputs.cleanup_resources }}
105+
existing_webapp_url: ${{ inputs.existing_webapp_url }}
106+
RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
107+
AZURE_LOCATION: ${{ needs.deploy.outputs.AZURE_LOCATION }}
108+
AZURE_ENV_OPENAI_LOCATION: ${{ needs.deploy.outputs.AZURE_ENV_OPENAI_LOCATION }}
109+
ENV_NAME: ${{ needs.deploy.outputs.ENV_NAME }}
110+
IMAGE_TAG: ${{ needs.deploy.outputs.IMAGE_TAG }}
111+
secrets: inherit
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Cleanup Deployment Job
2+
on:
3+
workflow_call:
4+
inputs:
5+
trigger_type:
6+
description: 'Trigger type (workflow_dispatch, pull_request, schedule)'
7+
required: true
8+
type: string
9+
cleanup_resources:
10+
description: 'Cleanup Deployed Resources'
11+
required: false
12+
default: false
13+
type: boolean
14+
existing_webapp_url:
15+
description: 'Existing Container WebApp URL (Skips Deployment)'
16+
required: false
17+
default: ''
18+
type: string
19+
RESOURCE_GROUP_NAME:
20+
description: 'Resource Group Name to cleanup'
21+
required: true
22+
type: string
23+
AZURE_LOCATION:
24+
description: 'Azure Location'
25+
required: true
26+
type: string
27+
AZURE_ENV_OPENAI_LOCATION:
28+
description: 'Azure OpenAI Location'
29+
required: true
30+
type: string
31+
ENV_NAME:
32+
description: 'Environment Name'
33+
required: true
34+
type: string
35+
IMAGE_TAG:
36+
description: 'Docker Image Tag'
37+
required: true
38+
type: string
39+
40+
jobs:
41+
cleanup-deployment:
42+
runs-on: ubuntu-latest
43+
continue-on-error: true
44+
env:
45+
RESOURCE_GROUP_NAME: ${{ inputs.RESOURCE_GROUP_NAME }}
46+
AZURE_LOCATION: ${{ inputs.AZURE_LOCATION }}
47+
AZURE_ENV_OPENAI_LOCATION: ${{ inputs.AZURE_ENV_OPENAI_LOCATION }}
48+
ENV_NAME: ${{ inputs.ENV_NAME }}
49+
IMAGE_TAG: ${{ inputs.IMAGE_TAG }}
50+
steps:
51+
- name: Setup Azure CLI
52+
shell: bash
53+
run: |
54+
if [[ "${{ runner.os }}" == "Linux" ]]; then
55+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
56+
fi
57+
az --version
58+
59+
- name: Login to Azure
60+
shell: bash
61+
run: |
62+
az login --service-principal --username ${{ secrets.AZURE_CLIENT_ID }} --password ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
63+
az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}
64+
65+
- name: Delete Resource Group (Optimized Cleanup)
66+
id: delete_rg
67+
shell: bash
68+
run: |
69+
set -e
70+
echo "🗑️ Starting optimized resource cleanup..."
71+
echo "Deleting resource group: ${{ env.RESOURCE_GROUP_NAME }}"
72+
73+
az group delete \
74+
--name "${{ env.RESOURCE_GROUP_NAME }}" \
75+
--yes \
76+
--no-wait
77+
78+
echo "✅ Resource group deletion initiated (running asynchronously)"
79+
echo "Note: Resources will be cleaned up in the background"
80+
81+
- name: Logout from Azure
82+
if: always()
83+
shell: bash
84+
run: |
85+
az logout || echo "Warning: Failed to logout from Azure CLI"
86+
echo "Logged out from Azure."
87+
88+
- name: Generate Cleanup Job Summary
89+
if: always()
90+
shell: bash
91+
run: |
92+
echo "## 🧹 Cleanup Job Summary" >> $GITHUB_STEP_SUMMARY
93+
echo "" >> $GITHUB_STEP_SUMMARY
94+
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
95+
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
96+
echo "| **Resource Group deletion Status** | ${{ steps.delete_rg.outcome == 'success' && '✅ Initiated' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
97+
echo "| **Resource Group** | \`${{ env.RESOURCE_GROUP_NAME }}\` |" >> $GITHUB_STEP_SUMMARY
98+
echo "" >> $GITHUB_STEP_SUMMARY
99+
if [[ "${{ steps.delete_rg.outcome }}" == "success" ]]; then
100+
echo "### ✅ Cleanup Details" >> $GITHUB_STEP_SUMMARY
101+
echo "- Successfully initiated deletion for Resource Group \`${{ env.RESOURCE_GROUP_NAME }}\`" >> $GITHUB_STEP_SUMMARY
102+
echo "" >> $GITHUB_STEP_SUMMARY
103+
else
104+
echo "### ❌ Cleanup Failed" >> $GITHUB_STEP_SUMMARY
105+
echo "- Cleanup process encountered an error" >> $GITHUB_STEP_SUMMARY
106+
echo "- Manual cleanup may be required for:" >> $GITHUB_STEP_SUMMARY
107+
echo " - Resource Group: \`${{ env.RESOURCE_GROUP_NAME }}\`" >> $GITHUB_STEP_SUMMARY
108+
echo "- Check the cleanup-deployment job logs for detailed error information" >> $GITHUB_STEP_SUMMARY
109+
fi

0 commit comments

Comments
 (0)