99 - cron : " 0 10,22 * * *" # Runs at 10:00 AM and 10:00 PM GMT
1010
1111env :
12- GPT_CAPACITY : 250
12+ GPT_CAPACITY : 150
1313 TEXT_EMBEDDING_CAPACITY : 200
1414
1515jobs :
@@ -42,11 +42,32 @@ jobs:
4242 - name : Install Helm
4343 shell : bash
4444 run : |
45- curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
46- sudo apt-get install apt-transport-https --yes
45+ # If helm is already available on the runner, print version and skip installation
46+ if command -v helm >/dev/null 2>&1; then
47+ echo "helm already installed: $(helm version --short 2>/dev/null || true)"
48+ exit 0
49+ fi
50+
51+ # Ensure prerequisites are present
52+ sudo apt-get update
53+ sudo apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
54+
55+ # Ensure keyrings dir exists
56+ sudo mkdir -p /usr/share/keyrings
57+
58+ # Add Helm GPG key (use -fS to fail fast on curl errors)
59+ curl -fsSL https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg >/dev/null
60+
61+ # Add the Helm apt repository
4762 echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
63+
64+ # Install helm
4865 sudo apt-get update
49- sudo apt-get install helm
66+ sudo apt-get install -y helm
67+
68+ # Verify
69+ echo "Installed helm version:"
70+ helm version
5071
5172 - name : Set up Docker
5273 uses : docker/setup-buildx-action@v3
@@ -112,48 +133,154 @@ jobs:
112133 if : env.QUOTA_FAILED == 'true'
113134 run : exit 1
114135
115- - name : Generate Environment Name
116- id : generate_environment_name
136+ - name : Install Bicep CLI
137+ run : az bicep install
138+
139+ - name : Install Azure Developer CLI
140+ run : |
141+ curl -fsSL https://aka.ms/install-azd.sh | bash
117142 shell : bash
143+
144+ - name : Set Deployment Region
145+ run : |
146+ echo "Selected Region: $VALID_REGION"
147+ echo "AZURE_LOCATION=$VALID_REGION" >> $GITHUB_ENV
148+
149+ - name : Generate Resource Group Name
150+ id : generate_rg_name
151+ run : |
152+ echo "Generating a unique resource group name..."
153+ ACCL_NAME="dkm" # Account name as specified
154+ SHORT_UUID=$(uuidgen | cut -d'-' -f1)
155+ UNIQUE_RG_NAME="arg-${ACCL_NAME}-${SHORT_UUID}"
156+ echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
157+ echo "Generated RESOURCE_GROUP_NAME: ${UNIQUE_RG_NAME}"
158+
159+ - name : Login to Azure
160+ run : |
161+ az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
162+ az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}
163+
164+ - name : Check and Create Resource Group
165+ id : check_create_rg
166+ run : |
167+ set -e
168+ echo "Checking if resource group exists..."
169+ rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
170+ if [ "$rg_exists" = "false" ]; then
171+ echo "Resource group does not exist. Creating..."
172+ az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location ${{ env.AZURE_LOCATION }} || { echo "Error creating resource group"; exit 1; }
173+ else
174+ echo "Resource group already exists."
175+ fi
176+ echo "RESOURCE_GROUP_NAME=${{ env.RESOURCE_GROUP_NAME }}" >> $GITHUB_OUTPUT
177+
178+ - name : Generate Unique Solution Prefix
179+ id : generate_solution_prefix
118180 run : |
119181 set -e
120- TIMESTAMP_SHORT=$(date +%s | tail -c 5) # Last 4-5 digits of epoch seconds
121- RANDOM_SUFFIX=$(head /dev/urandom | tr -dc 'a-z0-9' | head -c 8) # 8 random alphanum chars
122- UNIQUE_ENV_NAME="${TIMESTAMP_SHORT}${RANDOM_SUFFIX}" # Usually ~12-13 chars
123- echo "ENVIRONMENT_NAME=${UNIQUE_ENV_NAME}" >> $GITHUB_ENV
124- echo "Generated ENVIRONMENT_NAME: ${UNIQUE_ENV_NAME}"
182+ COMMON_PART="psldkm"
183+ TIMESTAMP=$(date +%s)
184+ UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 6)
185+ UNIQUE_SOLUTION_PREFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
186+ echo "SOLUTION_PREFIX=${UNIQUE_SOLUTION_PREFIX}" >> $GITHUB_ENV
187+ echo "Generated SOLUTION_PREFIX: ${UNIQUE_SOLUTION_PREFIX}"
188+
189+ - name : Deploy Bicep Template
190+ id : deploy
191+ run : |
192+ set -e
193+ az deployment group create \
194+ --name ${{ env.SOLUTION_PREFIX }}-deployment \
195+ --resource-group ${{ env.RESOURCE_GROUP_NAME }} \
196+ --template-file infra/main.bicep \
197+ --parameters \
198+ solutionName="${{ env.SOLUTION_PREFIX }}" \
199+ location=${{ env.AZURE_LOCATION }} \
200+ aiDeploymentsLocation=${{ env.AZURE_LOCATION }} \
201+ gptModelDeploymentType="GlobalStandard" \
202+ gptModelName="gpt-4.1-mini" \
203+ gptModelCapacity=${{ env.GPT_CAPACITY }} \
204+ gptModelVersion="2025-04-14" \
205+ embeddingModelName="text-embedding-3-large" \
206+ embeddingModelCapacity=${{ env.TEXT_EMBEDDING_CAPACITY }} \
207+ embeddingModelVersion="1" \
208+ enablePrivateNetworking=false \
209+ enableMonitoring=false \
210+ enableTelemetry=true \
211+ enableRedundancy=false \
212+ enableScalability=false \
213+ createdBy="Pipeline"
214+
215+ - name : Get Deployment Output and extract Values
216+ id : get_output
217+ run : |
218+ set -e
219+ echo "Fetching deployment output..."
220+ BICEP_OUTPUT=$(az deployment group show \
221+ --name ${{ env.SOLUTION_PREFIX }}-deployment \
222+ --resource-group ${{ env.RESOURCE_GROUP_NAME }} \
223+ --query "properties.outputs" -o json)
224+
225+ echo "Deployment outputs:"
226+ echo "$BICEP_OUTPUT"
227+
228+ # Write outputs to GitHub env
229+ # Loop through keys, normalize to uppercase, and export
230+ for key in $(echo "$BICEP_OUTPUT" | jq -r 'keys[]'); do
231+ value=$(echo "$BICEP_OUTPUT" | jq -r ".[\"$key\"].value")
232+ upper_key=$(echo "$key" | tr '[:lower:]' '[:upper:]')
233+ echo "$upper_key=$value" >> $GITHUB_ENV
234+ done
125235
126236 - name : Run Deployment Script with Input
127237 shell : pwsh
128238 run : |
129239 cd Deployment
130240 $input = @"
131- ${{ secrets.AZURE_TENANT_ID }}
132- ${{ secrets.AZURE_SUBSCRIPTION_ID }}
133- ${{ env.ENVIRONMENT_NAME }}
134-
135- CanadaCentral
136- ${{ env.VALID_REGION }}
137241 ${{ secrets.EMAIL }}
138242 yes
139243 "@
140244 $input | pwsh ./resourcedeployment.ps1
141- Write-Host "Resource Group Name is ${{ env.rg_name }}"
142- Write-Host "Kubernetes resource group are ${{ env.krg_name }}"
245+ Write-Host "Resource Group Name is ${{ env.RESOURCE_GROUP_NAME }}"
246+ Write-Host "Kubernetes resource group is ${{ env.AZURE_AKS_NAME }}"
143247 env :
248+ # From GitHub secrets (for login)
144249 AZURE_SUBSCRIPTION_ID : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
145- AZURE_TENANT_ID : ${{ secrets.AZURE_TENANT_ID }}
146- AZURE_CLIENT_ID : ${{ secrets.AZURE_CLIENT_ID }}
147- AZURE_CLIENT_SECRET : ${{ secrets.AZURE_CLIENT_SECRET }}
250+ AZURE_TENANT_ID : ${{ secrets.AZURE_TENANT_ID }}
251+ AZURE_CLIENT_ID : ${{ secrets.AZURE_CLIENT_ID }}
252+ AZURE_CLIENT_SECRET : ${{ secrets.AZURE_CLIENT_SECRET }}
253+
254+ # From deployment outputs step (these come from $GITHUB_ENV)
255+ RESOURCE_GROUP_NAME : ${{ env.RESOURCE_GROUP_NAME }}
256+ AZURE_RESOURCE_GROUP_ID : ${{ env.AZURE_RESOURCE_GROUP_ID }}
257+ STORAGE_ACCOUNT_NAME : ${{ env.STORAGE_ACCOUNT_NAME }}
258+ AZURE_SEARCH_SERVICE_NAME : ${{ env.AZURE_SEARCH_SERVICE_NAME }}
259+ AZURE_AKS_NAME : ${{ env.AZURE_AKS_NAME }}
260+ AZURE_AKS_MI_ID : ${{ env.AZURE_AKS_MI_ID }}
261+ AZURE_CONTAINER_REGISTRY_NAME : ${{ env.AZURE_CONTAINER_REGISTRY_NAME }}
262+ AZURE_COGNITIVE_SERVICE_NAME : ${{ env.AZURE_COGNITIVE_SERVICE_NAME }}
263+ AZURE_COGNITIVE_SERVICE_ENDPOINT : ${{ env.AZURE_COGNITIVE_SERVICE_ENDPOINT }}
264+ AZURE_OPENAI_SERVICE_NAME : ${{ env.AZURE_OPENAI_SERVICE_NAME }}
265+ AZURE_OPENAI_SERVICE_ENDPOINT : ${{ env.AZURE_OPENAI_SERVICE_ENDPOINT }}
266+ AZURE_COSMOSDB_NAME : ${{ env.AZURE_COSMOSDB_NAME }}
267+ AZ_GPT4O_MODEL_NAME : ${{ env.AZ_GPT4O_MODEL_NAME }}
268+ AZ_GPT4O_MODEL_ID : ${{ env.AZ_GPT4O_MODEL_ID }}
269+ AZ_GPT_EMBEDDING_MODEL_NAME : ${{ env.AZ_GPT_EMBEDDING_MODEL_NAME }}
270+ AZ_GPT_EMBEDDING_MODEL_ID : ${{ env.AZ_GPT_EMBEDDING_MODEL_ID }}
271+ AZURE_APP_CONFIG_ENDPOINT : ${{ env.AZURE_APP_CONFIG_ENDPOINT }}
272+ AZURE_APP_CONFIG_NAME : ${{ env.AZURE_APP_CONFIG_NAME }}
148273
149274 - name : Extract Web App URL and Increase TPM
150275 id : get_webapp_url
151276 shell : bash
152277 run : |
153278 # Save the resource group name and Kubernetes resource group name to GITHUB_OUTPUT
154- echo "RESOURCE_GROUP_NAME=${{ env.rg_name }}" >> $GITHUB_OUTPUT
279+ echo "RESOURCE_GROUP_NAME=${{ env.RESOURCE_GROUP_NAME }}" >> $GITHUB_OUTPUT
155280 echo "KUBERNETES_RESOURCE_GROUP_NAME=${{ env.krg_name }}" >> $GITHUB_OUTPUT
156281 echo "VALID_REGION=${{ env.VALID_REGION }}" >> $GITHUB_OUTPUT
282+ echo "OPENAI_RESOURCE_NAME=${{ env.AZURE_OPENAI_SERVICE_NAME }}" >> $GITHUB_OUTPUT
283+ echo "DOCUMENT_INTELLIGENCE_RESOURCE_NAME=${{ env.AZURE_COGNITIVE_SERVICE_NAME }}" >> $GITHUB_OUTPUT
157284
158285 if az account show &> /dev/null; then
159286 echo "Azure CLI is authenticated."
@@ -175,43 +302,6 @@ jobs:
175302 exit 1
176303 fi
177304
178- # Get Azure OpenAI resource name
179- openai_resource_name=$(az cognitiveservices account list --resource-group ${{ env.rg_name }} --query "[?kind=='OpenAI'].name | [0]" -o tsv)
180- if [ -z "$openai_resource_name" ]; then
181- echo "No Azure OpenAI resource found in the resource group."
182- exit 1
183- fi
184- echo "OpenAI resource name is $openai_resource_name"
185- echo "OPENAI_RESOURCE_NAME=$openai_resource_name" >> $GITHUB_OUTPUT
186-
187- # Get Azure Document Intelligence resource name
188- document_intelligence_resource_name=$(az cognitiveservices account list --resource-group ${{ env.rg_name }} --query "[?kind=='FormRecognizer'].name | [0]" -o tsv)
189- if [ -z "$document_intelligence_resource_name" ]; then
190- echo "No Azure Document Intelligence resource found in the resource group."
191- else
192- echo "Document Intelligence resource name is $document_intelligence_resource_name"
193- echo "DOCUMENT_INTELLIGENCE_RESOURCE_NAME=$document_intelligence_resource_name" >> $GITHUB_OUTPUT
194- fi
195-
196- # Increase the TPM for the Azure OpenAI models
197- echo "Increasing TPM for Azure OpenAI models..."
198- openai_gpt_deployment_url="/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.rg_name }}/providers/Microsoft.CognitiveServices/accounts/$openai_resource_name/deployments/gpt-4o-mini?api-version=2023-05-01"
199- az rest -m put -u "$openai_gpt_deployment_url" -b "{'sku':{'name':'GlobalStandard','capacity':${{ env.GPT_CAPACITY }}},'properties': {'model': {'format': 'OpenAI','name': 'gpt-4o-mini','version': '2024-07-18'}}}"
200- if [ $? -ne 0 ]; then
201- echo "Failed to increase TPM for GPT deployment."
202- exit 1
203- else
204- echo "Successfully increased TPM for GPT deployment."
205- fi
206- openai_embedding_deployment_url="/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.rg_name }}/providers/Microsoft.CognitiveServices/accounts/$openai_resource_name/deployments/text-embedding-large?api-version=2023-05-01"
207- az rest -m put -u "$openai_embedding_deployment_url" -b "{'sku':{'name':'GlobalStandard','capacity': ${{ env.TEXT_EMBEDDING_CAPACITY }}},'properties': {'model': {'format': 'OpenAI','name': 'text-embedding-3-large','version': '1'}}}"
208- if [ $? -ne 0 ]; then
209- echo "Failed to increase TPM for Text Embedding deployment."
210- exit 1
211- else
212- echo "Successfully increased TPM for Text Embedding deployment."
213- fi
214-
215305 - name : Validate Deployment
216306 shell : bash
217307 run : |
@@ -283,7 +373,6 @@ jobs:
283373 echo "Azure CLI is not authenticated. Skipping logout."
284374 fi
285375
286-
287376 e2e-test :
288377 needs : deploy
289378 uses : ./.github/workflows/test-automation.yml
0 commit comments