Skip to content

Commit 1ae5e9c

Browse files
fix: Merging Dev changes to Main (#1530)
Co-authored-by: Ajit Padhi <[email protected]>
1 parent 9483a06 commit 1ae5e9c

File tree

15 files changed

+1105
-563
lines changed

15 files changed

+1105
-563
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,42 @@ updates:
77
- package-ecosystem: "github-actions"
88
directory: "/"
99
schedule:
10-
interval: "weekly"
10+
interval: "monthly"
11+
1112
commit-message:
1213
prefix: "build"
14+
target-branch: "dependabotchanges"
1315
- package-ecosystem: "pip"
1416
directory: "/"
1517
schedule:
16-
interval: "weekly"
18+
interval: "monthly"
19+
20+
1721
commit-message:
1822
prefix: "build"
1923
groups:
2024
langchain:
2125
patterns:
2226
- "langchain*"
2327
open-pull-requests-limit: 50
28+
target-branch: "dependabotchanges"
2429
- package-ecosystem: "npm"
2530
directory: "/code/frontend"
2631
schedule:
27-
interval: "weekly"
32+
interval: "monthly"
33+
34+
2835
commit-message:
2936
prefix: "build"
3037
open-pull-requests-limit: 50
38+
target-branch: "dependabotchanges"
3139
- package-ecosystem: "npm"
3240
directory: "/tests/integration/ui"
3341
schedule:
34-
interval: "weekly"
42+
interval: "monthly"
43+
44+
3545
commit-message:
3646
prefix: "build"
3747
open-pull-requests-limit: 50
48+
target-branch: "dependabotchanges"

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ on:
44
workflow_run:
55
workflows: [Tests]
66
types: [completed]
7-
branches: [main]
7+
branches:
8+
- main
9+
- dev
10+
- demo
811
pull_request:
9-
branches: [main]
12+
branches:
13+
- main
14+
- dev
15+
- demo
1016
types:
1117
- opened
1218
- ready_for_review
@@ -28,9 +34,9 @@ jobs:
2834
dockerfile: docker/Frontend.Dockerfile
2935
uses: ./.github/workflows/build-docker.yml
3036
with:
31-
registry: fruoccopublic.azurecr.io
32-
username: fruoccopublic
37+
registry: ${{ github.event.workflow_run.head_branch == 'main' && 'fruoccopublic.azurecr.io' || 'cwydcontainerreg.azurecr.io'}}
38+
username: ${{ github.event.workflow_run.head_branch == 'main' && 'fruoccopublic' || 'cwydcontainerreg'}}
3339
app_name: ${{ matrix.app_name }}
3440
dockerfile: ${{ matrix.dockerfile }}
35-
push: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' }}
41+
push: ${{ github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'dev' || github.event.workflow_run.head_branch == 'demo' }}
3642
secrets: inherit

.github/workflows/build-docker.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ on:
2121
secrets:
2222
DOCKER_PASSWORD:
2323
required: false
24+
DEV_DOCKER_PASSWORD:
25+
required: false
2426

2527
jobs:
2628
docker-build:
@@ -31,13 +33,21 @@ jobs:
3133
uses: actions/checkout@v4
3234

3335
- name: Docker Login
34-
if: ${{ inputs.push }}
36+
if: ${{ inputs.push == true && github.ref_name == 'main' }}
3537
uses: docker/login-action@v3
3638
with:
3739
registry: ${{ inputs.registry }}
3840
username: ${{ inputs.username }}
3941
password: ${{ secrets.DOCKER_PASSWORD }}
4042

43+
- name: Dev Docker Login
44+
if: ${{ inputs.push == true && (github.ref_name == 'dev' || github.ref_name == 'demo') }}
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ${{ inputs.registry }}
48+
username: ${{ inputs.username }}
49+
password: ${{ secrets.DEV_DOCKER_PASSWORD }}
50+
4151
- name: Set up Docker Buildx
4252
uses: docker/setup-buildx-action@v3
4353

@@ -51,7 +61,7 @@ jobs:
5161
context: .
5262
file: ${{ inputs.dockerfile }}
5363
push: ${{ inputs.push }}
54-
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:latest
64+
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || 'latest' }}
5565
tags: |
56-
${{ inputs.registry }}/${{ inputs.app_name}}:latest
66+
${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || 'latest' }}
5767
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.date.outputs.date }}_${{ github.run_number }}

.github/workflows/ci.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
- dev
8+
- demo
79
schedule:
810
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
911

@@ -34,6 +36,17 @@ jobs:
3436
username: ${{ github.repository_owner }}
3537
password: ${{ secrets.GITHUB_TOKEN }}
3638

39+
- name: Set imageTag
40+
id: set-image-tag
41+
run: |
42+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
43+
echo "imageTag=latest" >> $GITHUB_ENV
44+
elif [[ "${{ github.ref_name }}" == "main" ]]; then
45+
echo "imageTag=latest" >> $GITHUB_ENV
46+
else
47+
echo "imageTag=${{ github.ref_name }}" >> $GITHUB_ENV
48+
fi
49+
3750
- name: Pre-build image and run make in dev container
3851
uses: devcontainers/[email protected]
3952
env:
@@ -43,8 +56,9 @@ jobs:
4356
with:
4457
imageName: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
4558
cacheFrom: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
59+
imageTag: ${{ env.imageTag }}
4660
runCmd: make ci && make deploy
47-
refFilterForPush: refs/heads/main
61+
refFilterForPush: refs/heads/${{ github.event_name == 'schedule' && 'main' || github.ref_name }}
4862
env: |
4963
AZURE_CLIENT_ID
5064
AZURE_CLIENT_SECRET
@@ -64,6 +78,7 @@ jobs:
6478
with:
6579
push: never
6680
imageName: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
81+
imageTag: ${{ env.imageTag }}
6782
runCmd: make destroy
6883
env: |
6984
AZURE_CLIENT_ID
@@ -78,7 +93,6 @@ jobs:
7893
if: failure()
7994
run: |
8095
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
81-
8296
# Construct the email body
8397
EMAIL_BODY=$(cat <<EOF
8498
{

.github/workflows/sync-branches.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Sync Main to dependabotchanges
2+
3+
on:
4+
# Schedule the sync job to run daily or customize as needed
5+
schedule:
6+
- cron: '0 1 * * *' # Runs every day at 1 AM UTC
7+
# Trigger the sync job on pushes to the main branch
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
sync:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0 # Fetch all history for accurate branch comparison
21+
22+
- name: Configure Git
23+
run: |
24+
git config user.name "github-actions[bot]"
25+
git config user.email "github-actions[bot]@users.noreply.github.com"
26+
27+
- name: Sync main to dependabotchanges
28+
run: |
29+
# Ensure we're on the main branch
30+
git checkout main
31+
# Fetch the latest changes
32+
git pull origin main
33+
34+
# Switch to dependabotchanges branch
35+
git checkout dependabotchanges
36+
# Merge main branch changes
37+
git merge main --no-edit
38+
39+
# Push changes back to dependabotchanges branch
40+
git push origin dependabotchanges
41+
42+
- name: Notify on Failure
43+
if: failure()
44+
run: echo "Sync from main to dependabotchanges failed!"

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Tests
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, dev, demo]
66
pull_request:
7-
branches: [main]
7+
branches: [main, dev, demo]
88
types:
99
- opened
1010
- ready_for_review

code/create_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_markdown_url(source, title, container_sas):
4242

4343

4444
def get_citations(citation_list):
45-
"""Returns Formated Citations"""
45+
"""Returns Formated Citations."""
4646
blob_client = AzureBlobStorageClient()
4747
container_sas = blob_client.get_container_sas()
4848
citations_dict = {"citations": []}

infra/app/function.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module function '../core/host/functions.bicep' = {
4242
runtimeName: runtimeName
4343
runtimeVersion: runtimeVersion
4444
dockerFullImageName: dockerFullImageName
45+
useKeyVault: useKeyVault
4546
appSettings: union(appSettings, {
4647
WEBSITES_ENABLE_APP_SERVICE_STORAGE: 'false'
4748
AZURE_AUTH_TYPE: authType

infra/app/web.bicep

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,16 @@ module web '../core/host/appservice.bicep' = {
122122
'2023-05-01'
123123
).key1
124124
AZURE_COSMOSDB_ACCOUNT_KEY: (useKeyVault || cosmosDBKeyName == '')
125-
? cosmosDBKeyName
126-
: listKeys(
127-
resourceId(
128-
subscription().subscriptionId,
129-
resourceGroup().name,
130-
'Microsoft.DocumentDB/databaseAccounts',
131-
cosmosDBKeyName
132-
),
133-
'2022-08-15'
134-
).primaryMasterKey
125+
? cosmosDBKeyName
126+
: listKeys(
127+
resourceId(
128+
subscription().subscriptionId,
129+
resourceGroup().name,
130+
'Microsoft.DocumentDB/databaseAccounts',
131+
cosmosDBKeyName
132+
),
133+
'2022-08-15'
134+
).primaryMasterKey
135135
})
136136
keyVaultName: keyVaultName
137137
runtimeName: runtimeName
@@ -192,6 +192,22 @@ module webaccess '../core/security/keyvault-access.bicep' = if (useKeyVault) {
192192
}
193193
}
194194

195+
resource cosmosRoleDefinition 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions@2024-05-15' existing = {
196+
name: '${json(appSettings.AZURE_COSMOSDB_INFO).accountName}/00000000-0000-0000-0000-000000000002'
197+
}
198+
199+
module cosmosUserRole '../core/database/cosmos-sql-role-assign.bicep' = {
200+
name: 'cosmos-sql-user-role-${web.name}'
201+
params: {
202+
accountName: json(appSettings.AZURE_COSMOSDB_INFO).accountName
203+
roleDefinitionId: cosmosRoleDefinition.id
204+
principalId: web.outputs.identityPrincipalId
205+
}
206+
dependsOn: [
207+
cosmosRoleDefinition
208+
]
209+
}
210+
195211
output FRONTEND_API_IDENTITY_PRINCIPAL_ID string = web.outputs.identityPrincipalId
196212
output FRONTEND_API_NAME string = web.outputs.name
197213
output FRONTEND_API_URI string = web.outputs.uri
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
metadata description = 'Creates a SQL role assignment under an Azure Cosmos DB account.'
2+
param accountName string
3+
4+
param roleDefinitionId string
5+
param principalId string = ''
6+
7+
resource role 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-15' = {
8+
parent: cosmos
9+
name: guid(roleDefinitionId, principalId, cosmos.id)
10+
properties: {
11+
principalId: principalId
12+
roleDefinitionId: roleDefinitionId
13+
scope: cosmos.id
14+
}
15+
}
16+
17+
resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' existing = {
18+
name: accountName
19+
}

0 commit comments

Comments
 (0)