Skip to content

Commit 114c038

Browse files
2 parents c55ff18 + 5e92c83 commit 114c038

64 files changed

Lines changed: 5184 additions & 1823 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: AZD Template Validation
2+
3+
on:
4+
schedule:
5+
- cron: '30 1 * * 4' # Every Thursday at 7:00 AM IST (1:30 AM UTC)
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
pull-requests: write
12+
13+
jobs:
14+
template_validation:
15+
runs-on: ubuntu-latest
16+
name: azd template validation
17+
environment: production
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v6
21+
22+
- name: Set timestamp
23+
run: echo "HHMM=$(date -u +'%H%M')" >> $GITHUB_ENV
24+
25+
- name: Validate Azure Template
26+
id: validation
27+
uses: microsoft/template-validation-action@v0.4.3
28+
with:
29+
validateAzd: ${{ vars.TEMPLATE_VALIDATE_AZD }}
30+
validateTests: ${{ vars.TEMPLATE_VALIDATE_TESTS }}
31+
useDevContainer: ${{ vars.TEMPLATE_USE_DEV_CONTAINER }}
32+
33+
env:
34+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
35+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
36+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
37+
AZURE_ENV_NAME: azd-${{ secrets.AZURE_ENV_NAME }}-${{ env.HHMM }}
38+
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
39+
AZURE_ENV_AI_SERVICE_LOCATION: ${{ secrets.AZURE_AI_DEPLOYMENT_LOCATION || secrets.AZURE_LOCATION }}
40+
AZURE_ENV_MODEL_CAPACITY: 1
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
AZURE_DEV_COLLECT_TELEMETRY: ${{ vars.AZURE_DEV_COLLECT_TELEMETRY }}
43+
44+
- name: Print result
45+
shell: bash
46+
run: cat "${{ steps.validation.outputs.resultFile }}"

.github/workflows/azure-dev.yml

Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,65 @@
1-
name: Azure Template Validation
2-
on:
3-
workflow_dispatch:
4-
5-
permissions:
6-
contents: read
7-
id-token: write
8-
pull-requests: write
9-
jobs:
10-
template_validation_job:
11-
runs-on: ubuntu-latest
1+
name: Azure Dev Deploy
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
id-token: write
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
1213
environment: production
13-
name: Template validation
14-
steps:
15-
# Step 1: Checkout the code from your repository
16-
- name: Checkout code
17-
uses: actions/checkout@v6
18-
# Step 2: Validate the Azure template using microsoft/template-validation-action
19-
- name: Validate Azure Template
20-
uses: microsoft/template-validation-action@v0.4.4
21-
with:
22-
validateAzd: true
23-
useDevContainer: false
24-
id: validation
25-
env:
26-
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
27-
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
28-
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
29-
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
30-
AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }}
31-
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
32-
AZURE_AI_DEPLOYMENT_LOCATION : ${{ secrets.AZURE_AI_DEPLOYMENT_LOCATION }}
33-
AZURE_ENV_MODEL_CAPACITY : 1
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
AZURE_DEV_COLLECT_TELEMETRY: ${{ vars.AZURE_DEV_COLLECT_TELEMETRY }}
36-
# Step 3: Print the result of the validation
37-
- name: Print result
38-
run: cat ${{ steps.validation.outputs.resultFile }}
14+
env:
15+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
16+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
17+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
18+
AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }}
19+
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
20+
AZURE_AI_DEPLOYMENT_LOCATION: ${{ secrets.AZURE_AI_DEPLOYMENT_LOCATION || secrets.AZURE_LOCATION }}
21+
AZURE_ENV_GPT_MODEL_CAPACITY: 1
22+
AZURE_DEV_COLLECT_TELEMETRY: ${{ vars.AZURE_DEV_COLLECT_TELEMETRY }}
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
27+
- name: Set timestamp and env name
28+
run: |
29+
HHMM=$(date -u +'%H%M')
30+
echo "AZURE_ENV_NAME=azd-${{ vars.AZURE_ENV_NAME }}-${HHMM}" >> $GITHUB_ENV
31+
32+
- name: Install azd
33+
uses: Azure/setup-azd@v2
34+
35+
- name: Login to Azure
36+
uses: azure/login@v2
37+
with:
38+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
39+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
40+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
41+
42+
- name: Login to AZD
43+
shell: bash
44+
run: |
45+
azd auth login \
46+
--client-id "$AZURE_CLIENT_ID" \
47+
--federated-credential-provider "github" \
48+
--tenant-id "$AZURE_TENANT_ID"
49+
50+
- name: Provision and deploy
51+
shell: bash
52+
run: |
53+
set -e
54+
55+
if ! azd env select "$AZURE_ENV_NAME"; then
56+
azd env new "$AZURE_ENV_NAME" --subscription "$AZURE_SUBSCRIPTION_ID" --location "$AZURE_LOCATION" --no-prompt
57+
fi
58+
59+
azd config set defaults.subscription "$AZURE_SUBSCRIPTION_ID"
60+
azd env set AZURE_SUBSCRIPTION_ID "$AZURE_SUBSCRIPTION_ID"
61+
azd env set AZURE_LOCATION "$AZURE_LOCATION"
62+
azd env set AZURE_ENV_AI_SERVICE_LOCATION "${AZURE_AI_DEPLOYMENT_LOCATION:-$AZURE_LOCATION}"
63+
azd env set AZURE_ENV_GPT_MODEL_CAPACITY "$AZURE_ENV_GPT_MODEL_CAPACITY"
64+
65+
azd up --no-prompt

.github/workflows/build-docker-images.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build Docker and Optional Push
22
permissions:
33
contents: read
44
actions: read
5+
id-token: write
56
on:
67
push:
78
branches:
@@ -50,15 +51,11 @@ jobs:
5051
include:
5152
- app_name: cmsabackend
5253
dockerfile: docker/Backend.Dockerfile
53-
password_secret: DOCKER_PASSWORD
5454
- app_name: cmsafrontend
5555
dockerfile: docker/Frontend.Dockerfile
56-
password_secret: DOCKER_PASSWORD
5756
uses: ./.github/workflows/build-docker.yml
5857
with:
5958
registry: cmsacontainerreg.azurecr.io
60-
username: cmsacontainerreg
61-
password_secret: ${{ matrix.password_secret }}
6259
app_name: ${{ matrix.app_name }}
6360
dockerfile: ${{ matrix.dockerfile }}
6461
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}

.github/workflows/build-docker.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ on:
66
registry:
77
required: true
88
type: string
9-
username:
10-
required: true
11-
type: string
12-
password_secret:
13-
required: true
14-
type: string
159
app_name:
1610
required: true
1711
type: string
@@ -21,25 +15,27 @@ on:
2115
push:
2216
required: true
2317
type: boolean
24-
secrets:
25-
DOCKER_PASSWORD:
26-
required: false
2718

2819
jobs:
2920
docker-build:
3021
runs-on: ubuntu-latest
22+
environment: production
3123
steps:
3224

3325
- name: Checkout
3426
uses: actions/checkout@v6
3527

36-
- name: Docker Login
28+
- name: Login to Azure
3729
if: ${{ inputs.push }}
38-
uses: docker/login-action@v4
30+
uses: azure/login@v2
3931
with:
40-
registry: ${{ inputs.registry }}
41-
username: ${{ inputs.username }}
42-
password: ${{ secrets[inputs.password_secret] }}
32+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
33+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
34+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
35+
36+
- name: Login to ACR
37+
if: ${{ inputs.push }}
38+
run: az acr login --name ${{ inputs.registry }}
4339

4440
- name: Set up Docker Buildx
4541
uses: docker/setup-buildx-action@v4

.github/workflows/deploy-orchestrator.yml

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Deployment orchestrator
22

3-
permissions:
4-
contents: read
5-
actions: read
6-
73
on:
84
workflow_call:
95
inputs:
@@ -46,13 +42,13 @@ on:
4642
required: false
4743
default: 'GoldenPath-Testing'
4844
type: string
49-
AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID:
50-
description: 'Log Analytics Workspace ID (Optional)'
45+
AZURE_ENV_EXISTING_LOG_ANALYTICS_WORKSPACE_RID:
46+
description: 'Log Analytics Workspace Resource ID (Optional)'
5147
required: false
5248
default: ''
5349
type: string
54-
AZURE_EXISTING_AI_PROJECT_RESOURCE_ID:
55-
description: 'AI Project Resource ID (Optional)'
50+
AZURE_EXISTING_AIPROJECT_RESOURCE_ID:
51+
description: 'Foundry Project Resource ID (Optional)'
5652
required: false
5753
default: ''
5854
type: string
@@ -90,8 +86,8 @@ jobs:
9086
EXP: ${{ inputs.EXP }}
9187
build_docker_image: ${{ inputs.build_docker_image }}
9288
existing_webapp_url: ${{ inputs.existing_webapp_url }}
93-
AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID: ${{ inputs.AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID }}
94-
AZURE_EXISTING_AI_PROJECT_RESOURCE_ID: ${{ inputs.AZURE_EXISTING_AI_PROJECT_RESOURCE_ID }}
89+
AZURE_ENV_EXISTING_LOG_ANALYTICS_WORKSPACE_RID: ${{ inputs.AZURE_ENV_EXISTING_LOG_ANALYTICS_WORKSPACE_RID }}
90+
AZURE_EXISTING_AIPROJECT_RESOURCE_ID: ${{ inputs.AZURE_EXISTING_AIPROJECT_RESOURCE_ID }}
9591
docker_image_tag: ${{ needs.docker-build.outputs.IMAGE_TAG }}
9692
run_e2e_tests: ${{ inputs.run_e2e_tests }}
9793
cleanup_resources: ${{ inputs.cleanup_resources }}
@@ -106,9 +102,25 @@ jobs:
106102
TEST_SUITE: ${{ inputs.trigger_type == 'workflow_dispatch' && inputs.run_e2e_tests || 'GoldenPath-Testing' }}
107103
secrets: inherit
108104

105+
cleanup-deployment:
106+
if: "!cancelled() && needs.deploy.result == 'success' && needs.deploy.outputs.RESOURCE_GROUP_NAME != '' && inputs.existing_webapp_url == '' && (inputs.trigger_type != 'workflow_dispatch' || inputs.cleanup_resources)"
107+
needs: [docker-build, deploy, e2e-test]
108+
uses: ./.github/workflows/job-cleanup-deployment.yml
109+
with:
110+
runner_os: ${{ inputs.runner_os }}
111+
trigger_type: ${{ inputs.trigger_type }}
112+
cleanup_resources: ${{ inputs.cleanup_resources }}
113+
existing_webapp_url: ${{ inputs.existing_webapp_url }}
114+
RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
115+
AZURE_LOCATION: ${{ needs.deploy.outputs.AZURE_LOCATION }}
116+
AZURE_ENV_OPENAI_LOCATION: ${{ needs.deploy.outputs.AZURE_ENV_OPENAI_LOCATION }}
117+
ENV_NAME: ${{ needs.deploy.outputs.ENV_NAME }}
118+
IMAGE_TAG: ${{ needs.deploy.outputs.IMAGE_TAG }}
119+
secrets: inherit
120+
109121
send-notification:
110122
if: "!cancelled()"
111-
needs: [docker-build, deploy, e2e-test]
123+
needs: [docker-build, deploy, e2e-test, cleanup-deployment]
112124
uses: ./.github/workflows/job-send-notification.yml
113125
with:
114126
trigger_type: ${{ inputs.trigger_type }}
@@ -123,20 +135,5 @@ jobs:
123135
QUOTA_FAILED: ${{ needs.deploy.outputs.QUOTA_FAILED }}
124136
TEST_SUCCESS: ${{ needs.e2e-test.outputs.TEST_SUCCESS }}
125137
TEST_REPORT_URL: ${{ needs.e2e-test.outputs.TEST_REPORT_URL }}
126-
secrets: inherit
127-
128-
cleanup-deployment:
129-
if: "!cancelled() && needs.deploy.result == 'success' && needs.deploy.outputs.RESOURCE_GROUP_NAME != '' && inputs.existing_webapp_url == '' && (inputs.trigger_type != 'workflow_dispatch' || inputs.cleanup_resources)"
130-
needs: [docker-build, deploy, e2e-test]
131-
uses: ./.github/workflows/job-cleanup-deployment.yml
132-
with:
133-
runner_os: ${{ inputs.runner_os }}
134-
trigger_type: ${{ inputs.trigger_type }}
135-
cleanup_resources: ${{ inputs.cleanup_resources }}
136-
existing_webapp_url: ${{ inputs.existing_webapp_url }}
137-
RESOURCE_GROUP_NAME: ${{ needs.deploy.outputs.RESOURCE_GROUP_NAME }}
138-
AZURE_LOCATION: ${{ needs.deploy.outputs.AZURE_LOCATION }}
139-
AZURE_ENV_OPENAI_LOCATION: ${{ needs.deploy.outputs.AZURE_ENV_OPENAI_LOCATION }}
140-
ENV_NAME: ${{ needs.deploy.outputs.ENV_NAME }}
141-
IMAGE_TAG: ${{ needs.deploy.outputs.IMAGE_TAG }}
138+
cleanup_result: ${{ needs.cleanup-deployment.result }}
142139
secrets: inherit

0 commit comments

Comments
 (0)