From 1d58f2b516bc6bb7c9cac08040c5ddeb1a7569c8 Mon Sep 17 00:00:00 2001 From: marumaru1019 <70362624+marumaru1019@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:21:02 +0900 Subject: [PATCH] =?UTF-8?q?Gitub=20Actions=20=E3=81=AE=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=82=92=E8=A7=A3=E6=B6=88=20(#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/5.internal-document-search-deploy.yml | 7 ++++--- .github/workflows/5.what-if.yml | 6 +++--- 5.internal-document-search/infra/main.bicep | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/5.internal-document-search-deploy.yml b/.github/workflows/5.internal-document-search-deploy.yml index 84305c4..388cc43 100644 --- a/.github/workflows/5.internal-document-search-deploy.yml +++ b/.github/workflows/5.internal-document-search-deploy.yml @@ -19,10 +19,11 @@ jobs: - name: what-if using Azure CLI run: | - results=$(az deployment sub what-if --template-file "./5.internal-document-search/infra/main.bicep" --location JapanEast -p vmLoginPassword=dummy -p resourceGroupName=rg-${{ github.run_id }} -p isPrivateNetworkEnabled=false -p environmentName=${{ github.run_id }} -p location=japaneast) + set +e + results=$(az deployment sub what-if --template-file "./5.internal-document-search/infra/main.bicep" --location JapanEast -p vmLoginPassword=dummy -p resourceGroupName=rg-${{ github.run_id }} -p isPrivateNetworkEnabled=false -p environmentName=${{ github.run_id }} -p location=japaneast 2>&1) echo "$results" # Check if "Error" is present in $results - if echo "$results" | grep "Error"; then + if echo "$results" | grep -i "Error"; then echo "Error found in what-if results. Exiting..." exit 1 fi @@ -46,7 +47,7 @@ jobs: $ENV:COGNITIVE_SERVICES_NAME = "cog-${{ github.run_id }}" cd 5.internal-document-search/infra - $results = az deployment sub create --name $ENV:DEP_NAME --location $ENV:LOC --template-file main.bicep --parameters principalId=$ENV:AZURE_PRINCIPAL_ID environmentName=$ENV:AZURE_ENV_NAME location=$ENV:LOC backendServiceName=$ENV:BACKEND_SERVICE_NAME appServicePlanName=$ENV:APP_SERVICE_PLAN_NAME storageAccountName=$ENV:STORAGE_ACCOUNT_NAME searchServiceName=$ENV:SEARCH_SERVICE_NAME formRecognizerServiceName=$ENV:FORMRECOGNIZER_SERVICE_NAME openAiServiceName=$ENV:COGNITIVE_SERVICES_NAME vmLoginPassword=dummy isPrivateNetworkEnabled=false + $results = az deployment sub create --name $ENV:DEP_NAME --location $ENV:LOC --template-file main.bicep --parameters principalId=$ENV:AZURE_PRINCIPAL_ID environmentName=$ENV:AZURE_ENV_NAME location=$ENV:LOC backendServiceName=$ENV:BACKEND_SERVICE_NAME appServicePlanName=$ENV:APP_SERVICE_PLAN_NAME storageAccountName=$ENV:STORAGE_ACCOUNT_NAME searchServiceName=$ENV:SEARCH_SERVICE_NAME formRecognizerServiceName=$ENV:FORMRECOGNIZER_SERVICE_NAME openAiServiceName=$ENV:COGNITIVE_SERVICES_NAME vmLoginPassword=dummy isPrivateNetworkEnabled=false cosmosDBAccountName=$ENV:AZURE_COSMOSDB_ACCOUNT 2>&1 | Out-String echo "$results" diff --git a/.github/workflows/5.what-if.yml b/.github/workflows/5.what-if.yml index f4c8fb8..166f5ea 100644 --- a/.github/workflows/5.what-if.yml +++ b/.github/workflows/5.what-if.yml @@ -17,11 +17,11 @@ jobs: - name: what-if using Azure CLI run: | - results=$(az deployment sub what-if --template-file "./5.internal-document-search/infra/main.bicep" --location JapanEast -p vmLoginPassword=dummy -p resourceGroupName=rg-${{ github.run_id }} -p isPrivateNetworkEnabled=false -p environmentName=${{ github.run_id }} -p location=japaneast) + set +e + results=$(az deployment sub what-if --template-file "./5.internal-document-search/infra/main.bicep" --location JapanEast -p vmLoginPassword=dummy -p resourceGroupName=rg-${{ github.run_id }} -p isPrivateNetworkEnabled=false -p environmentName=${{ github.run_id }} -p location=japaneast 2>&1) echo "$results" - # Check if "Error" is present in $results - if echo "$results" | grep "Error"; then + if echo "$results" | grep -i "Error"; then echo "Error found in what-if results. Exiting..." exit 1 fi \ No newline at end of file diff --git a/5.internal-document-search/infra/main.bicep b/5.internal-document-search/infra/main.bicep index 9cc96df..5ca7a04 100644 --- a/5.internal-document-search/infra/main.bicep +++ b/5.internal-document-search/infra/main.bicep @@ -52,6 +52,7 @@ param formRecognizerResourceGroupLocation string = location param formRecognizerSkuName string = 'S0' +param cosmosDBAccountName string = '' param cosmosDbDatabaseName string = 'ChatHistory' param cosmosDbContainerName string = 'Prompts' @@ -108,7 +109,7 @@ module cosmosDb 'core/db/cosmosdb.bicep' = { name: 'cosmosdb' scope: resourceGroup params: { - name: '${abbrs.documentDBDatabaseAccounts}${resourceToken}' + name: !empty(cosmosDBAccountName) ? cosmosDBAccountName : '${abbrs.documentDBDatabaseAccounts}${resourceToken}' location: location tags: union(tags, { 'azd-service-name': 'cosmosdb' }) cosmosDbDatabaseName: cosmosDbDatabaseName