Skip to content

Commit 7b5d8ee

Browse files
Merge pull request #2 from Vamshi-Microsoft/vk-deploy-dockerparam
feat: merge dockerparam into main
2 parents 1c00d6f + 0d9a4bc commit 7b5d8ee

2 files changed

Lines changed: 113 additions & 26 deletions

File tree

.github/workflows/deploy-unified.yml renamed to .github/workflows/deploy-Parameterized.yml

Lines changed: 112 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
name: Deploy-Test-Cleanup (Parameterized)
22
on:
3+
pull_request:
4+
branches:
5+
- main
6+
workflow_run:
7+
workflows: ["Build Docker and Optional Push"]
8+
types:
9+
- completed
10+
branches:
11+
- main
12+
- dev
13+
- demo
314
workflow_dispatch:
415
inputs:
516
run_e2e_tests:
@@ -32,17 +43,27 @@ on:
3243
required: false
3344
default: ''
3445
type: string
46+
build_docker_image:
47+
description: 'Build and push new Docker image'
48+
required: false
49+
default: false
50+
type: boolean
51+
schedule:
52+
- cron: "0 6,18 * * *" # Runs at 6:00 AM and 6:00 PM GMT
3553

3654

3755

3856
env:
3957
GPT_MIN_CAPACITY: 150
4058
TEXT_EMBEDDING_MIN_CAPACITY: 80
4159
BRANCH_NAME: ${{ github.event.workflow_run.head_branch || github.head_ref || github.ref_name }}
42-
WAF_ENABLED: ${{ github.event.inputs.waf_enabled || false }}
43-
EXP: ${{ github.event.inputs.EXP || false }}
44-
CLEANUP_RESOURCES: ${{ github.event.inputs.cleanup_resources || true }}
45-
RUN_E2E_TESTS: ${{ github.event.inputs.run_e2e_tests || true }}
60+
# For automatic triggers (pull_request, workflow_run, schedule): force Non-WAF + Non-EXP
61+
# For manual dispatch: use input values or defaults
62+
WAF_ENABLED: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.waf_enabled || false) || false }}
63+
EXP: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.EXP || false) || false }}
64+
CLEANUP_RESOURCES: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.cleanup_resources || true) || true }}
65+
RUN_E2E_TESTS: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.run_e2e_tests || true) || true }}
66+
BUILD_DOCKER_IMAGE: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.build_docker_image || false) || false }}
4667

4768
jobs:
4869
deploy:
@@ -54,11 +75,34 @@ jobs:
5475
AZURE_LOCATION: ${{ steps.set_region.outputs.AZURE_LOCATION }}
5576
IMAGE_TAG: ${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
5677
env:
57-
WAF_ENABLED: ${{ github.event.inputs.waf_enabled || true }}
58-
EXP: ${{ github.event.inputs.EXP || false }}
59-
CLEANUP_RESOURCES: ${{ github.event.inputs.cleanup_resources || true }}
78+
# For automatic triggers: force Non-WAF + Non-EXP, for manual dispatch: use inputs
79+
WAF_ENABLED: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.waf_enabled || false) || false }}
80+
EXP: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.EXP || false) || false }}
81+
CLEANUP_RESOURCES: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.cleanup_resources || true) || true }}
6082

6183
steps:
84+
- name: Display Workflow Configuration
85+
run: |
86+
echo "🚀 ==================================="
87+
echo "📋 WORKFLOW CONFIGURATION SUMMARY"
88+
echo "🚀 ==================================="
89+
echo "Trigger Type: ${{ github.event_name }}"
90+
echo "Branch: ${{ env.BRANCH_NAME }}"
91+
echo ""
92+
echo "Configuration Settings:"
93+
echo " • WAF Enabled: ${{ env.WAF_ENABLED }}"
94+
echo " • EXP Enabled: ${{ env.EXP }}"
95+
echo " • Run E2E Tests: ${{ env.RUN_E2E_TESTS }}"
96+
echo " • Cleanup Resources: ${{ env.CLEANUP_RESOURCES }}"
97+
echo " • Build Docker Image: ${{ env.BUILD_DOCKER_IMAGE }}"
98+
echo ""
99+
if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
100+
echo "ℹ️ Automatic Trigger: Using Non-WAF + Non-EXP configuration"
101+
else
102+
echo "ℹ️ Manual Trigger: Using user-specified configuration"
103+
fi
104+
echo "🚀 ==================================="
105+
62106
- name: Validate EXP Configuration
63107
run: |
64108
echo "🔍 Validating EXP configuration..."
@@ -194,28 +238,57 @@ jobs:
194238
- name: Generate Unique Docker Image Tag
195239
id: generate_docker_tag
196240
run: |
197-
# Generate unique tag for manual deployment runs
198-
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
199-
RUN_ID="${{ github.run_id }}"
200-
BRANCH_NAME="${{ env.BRANCH_NAME }}"
201-
# Sanitize branch name for Docker tag (replace invalid characters with hyphens)
202-
CLEAN_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g' | sed 's/--*/-/g' | sed 's/^-\|-$//g')
203-
UNIQUE_TAG="${CLEAN_BRANCH_NAME}-${TIMESTAMP}-${RUN_ID}"
204-
echo "IMAGE_TAG=$UNIQUE_TAG" >> $GITHUB_ENV
205-
echo "IMAGE_TAG=$UNIQUE_TAG" >> $GITHUB_OUTPUT
206-
echo "Generated unique Docker tag: $UNIQUE_TAG"
241+
if [[ "${{ env.BUILD_DOCKER_IMAGE }}" == "true" ]]; then
242+
echo "🔨 Building new Docker image - generating unique tag..."
243+
# Generate unique tag for manual deployment runs
244+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
245+
RUN_ID="${{ github.run_id }}"
246+
BRANCH_NAME="${{ env.BRANCH_NAME }}"
247+
# Sanitize branch name for Docker tag (replace invalid characters with hyphens)
248+
CLEAN_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g' | sed 's/--*/-/g' | sed 's/^-\|-$//g')
249+
UNIQUE_TAG="${CLEAN_BRANCH_NAME}-${TIMESTAMP}-${RUN_ID}"
250+
echo "IMAGE_TAG=$UNIQUE_TAG" >> $GITHUB_ENV
251+
echo "IMAGE_TAG=$UNIQUE_TAG" >> $GITHUB_OUTPUT
252+
echo "Generated unique Docker tag: $UNIQUE_TAG"
253+
else
254+
echo "🏷️ Using existing Docker image based on branch..."
255+
BRANCH_NAME="${{ env.BRANCH_NAME }}"
256+
echo "Current branch: $BRANCH_NAME"
257+
258+
# Determine image tag based on branch
259+
if [[ "$BRANCH_NAME" == "main" ]]; then
260+
IMAGE_TAG="latest_waf"
261+
echo "Using main branch - image tag: latest_waf"
262+
elif [[ "$BRANCH_NAME" == "dev" ]]; then
263+
IMAGE_TAG="dev"
264+
echo "Using dev branch - image tag: dev"
265+
elif [[ "$BRANCH_NAME" == "demo" ]]; then
266+
IMAGE_TAG="demo"
267+
echo "Using demo branch - image tag: demo"
268+
else
269+
IMAGE_TAG="latest_waf"
270+
echo "Using default for branch '$BRANCH_NAME' - image tag: latest_waf"
271+
fi
272+
273+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
274+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
275+
echo "Using existing Docker image tag: $IMAGE_TAG"
276+
fi
207277
208278
- name: Set up Docker Buildx
279+
if: env.BUILD_DOCKER_IMAGE == true
209280
uses: docker/setup-buildx-action@v3
210281

211282
- name: Log in to Azure Container Registry
283+
if: env.BUILD_DOCKER_IMAGE == true
212284
uses: azure/docker-login@v2
213285
with:
214286
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }}
215287
username: ${{ secrets.ACR_DEV_USERNAME }}
216288
password: ${{ secrets.ACR_DEV_PASSWORD }}
217289

218290
- name: Build and Push Docker Image
291+
if: env.BUILD_DOCKER_IMAGE == true
219292
id: build_push_image
220293
uses: docker/build-push-action@v6
221294
with:
@@ -227,11 +300,18 @@ jobs:
227300
${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
228301
229302
- name: Verify Docker Image Build
303+
if: env.BUILD_DOCKER_IMAGE == true
230304
run: |
231305
echo "✅ Docker image successfully built and pushed"
232306
echo "Image tag: ${{ env.IMAGE_TAG }}"
233307
echo "Run number: ${{ github.run_number }}"
234308
309+
- name: Verify Docker Image Selection
310+
if: env.BUILD_DOCKER_IMAGE == false
311+
run: |
312+
echo "✅ Using existing Docker image: latest_waf"
313+
echo "Image tag: ${{ env.IMAGE_TAG }}"
314+
235315
- name: Generate Unique Environment Name
236316
id: generate_env_name
237317
run: |
@@ -294,10 +374,15 @@ jobs:
294374
azd env set AZURE_RESOURCE_GROUP="$RESOURCE_GROUP_NAME"
295375
azd env set AZURE_ENV_IMAGETAG="${{ env.IMAGE_TAG }}"
296376
297-
# Extract ACR name from login server and set as environment variable
298-
ACR_NAME=$(echo "${{ secrets.ACR_DEV_LOGIN_SERVER }}" | cut -d'.' -f1)
299-
azd env set AZURE_ENV_ACR_NAME="$ACR_NAME"
300-
echo "Set ACR name to: $ACR_NAME"
377+
# Set ACR name only when building Docker image
378+
if [[ "${{ env.BUILD_DOCKER_IMAGE }}" == "true" ]]; then
379+
# Extract ACR name from login server and set as environment variable
380+
ACR_NAME=$(echo "${{ secrets.ACR_DEV_LOGIN_SERVER }}" | cut -d'.' -f1)
381+
azd env set AZURE_ENV_ACR_NAME="$ACR_NAME"
382+
echo "Set ACR name to: $ACR_NAME"
383+
else
384+
echo "Skipping ACR name configuration (using existing image)"
385+
fi
301386
302387
if [[ "${{ env.EXP }}" == "true" ]]; then
303388
echo "✅ EXP ENABLED - Setting EXP parameters..."
@@ -406,15 +491,17 @@ jobs:
406491
echo "Logged out from Azure."
407492
408493
e2e-test:
409-
if: github.event.inputs.run_e2e_tests == true || github.event.inputs.run_e2e_tests == null
494+
# Run e2e tests for automatic triggers or when manually enabled
495+
if: github.event_name != 'workflow_dispatch' || github.event.inputs.run_e2e_tests == true || github.event.inputs.run_e2e_tests == null
410496
needs: deploy
411497
uses: ./.github/workflows/test-automation.yml
412498
with:
413499
DOCGEN_URL: ${{ needs.deploy.outputs.WEBAPP_URL }}
414500
secrets: inherit
415501

416502
cleanup-deployment:
417-
if: always() && needs.deploy.outputs.RESOURCE_GROUP_NAME != '' && (github.event.inputs.cleanup_resources == true || github.event.inputs.cleanup_resources == null)
503+
# Cleanup for automatic triggers or when manually enabled
504+
if: always() && needs.deploy.outputs.RESOURCE_GROUP_NAME != '' && (github.event_name != 'workflow_dispatch' || github.event.inputs.cleanup_resources == true || github.event.inputs.cleanup_resources == null)
418505
needs: [deploy]
419506
runs-on: ubuntu-latest
420507
env:
@@ -450,7 +537,7 @@ jobs:
450537
set -e
451538
echo "🗑️ Cleaning up Docker images from Azure Container Registry..."
452539
453-
if [[ -n "${{ env.IMAGE_TAG }}" ]]; then
540+
if [[ -n "${{ env.IMAGE_TAG }}" && "${{ env.IMAGE_TAG }}" != "latest_waf" ]]; then
454541
echo "Deleting Docker images with tag: ${{ env.IMAGE_TAG }}"
455542
456543
# Delete the main image
@@ -465,7 +552,7 @@ jobs:
465552
466553
echo "✅ Docker images cleanup completed"
467554
else
468-
echo "⚠️ No IMAGE_TAG found, skipping Docker image cleanup"
555+
echo "⚠️ Skipping Docker image cleanup (using latest_waf or no custom image tag)"
469556
fi
470557
471558
- name: Select Environment

infra/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ module aiSearch 'br/public:avm/res/search/search-service:0.11.1' = {
623623
diagnosticSettings: enableMonitoring ? [{ workspaceResourceId: logAnalyticsWorkspaceResourceId }] : null
624624
disableLocalAuth: false
625625
hostingMode: 'default'
626-
sku: enableScalability ? 'standard' : 'basic'
626+
sku: enableScalability ? 'standard' : 'standard'
627627
managedIdentities: { systemAssigned: true }
628628
networkRuleSet: {
629629
bypass: 'AzureServices'

0 commit comments

Comments
 (0)