From 040d2bcb73f12d6ec6d1afe47b394977fc1ca9db Mon Sep 17 00:00:00 2001 From: John Rampono Date: Sat, 1 May 2021 06:35:05 +0800 Subject: [PATCH] Editing Deployment Scripts --- .github/workflows/Build_Development.yml | 24 +++--- .../Deployment/PushEnvFileIntoVariables.ps1 | 6 ++ .../Deployment/environments/development.json | 71 +++++++++-------- solution/Deployment/tbd.txt | 76 +++++++++++++++++++ 4 files changed, 128 insertions(+), 49 deletions(-) diff --git a/.github/workflows/Build_Development.yml b/.github/workflows/Build_Development.yml index 8c0b0ceb..bd7b6534 100644 --- a/.github/workflows/Build_Development.yml +++ b/.github/workflows/Build_Development.yml @@ -43,25 +43,25 @@ jobs: ParseEnvFile("$env:ENVIRONMENT_NAME") working-directory: ./solution/Deployment - - name: test env variable 0 - run: echo "${{ env.AdsOpts_Location }}" # This will output 'yellow' + - name: test that the AdsOpts variables have been set + run: echo "${{ env.AdsOpts_CD_Location }}" #Azure Function App Build - name: Restore dependencies for Function App - if: ${{env.TOGGLE_BUILD_FUNCTIONS==true}} + if: ${{env.AdsOpts_CI_BuildFunctionApp=="True"}} run: dotnet restore working-directory: ./solution/FunctionApp - name: Publish functions - if: ${{env.TOGGLE_BUILD_FUNCTIONS==true}} + if: ${{env.AdsOpts_CI_BuildFunctionApp=="True"}} run: dotnet publish --no-restore --configuration Release --output './deploy' working-directory: ./solution/FunctionApp - run: echo "starting Zip" - name: zip functions - if: ${{env.TOGGLE_BUILD_FUNCTIONS==true}} + if: ${{env.AdsOpts_CI_BuildFunctionApp=="True"}} run: zip -r ../publish.zip * working-directory: ./solution/FunctionApp/deploy - name: Package functions - if: ${{env.TOGGLE_BUILD_FUNCTIONS==true}} + if: ${{env.AdsOpts_CI_BuildFunctionApp=="True"}} uses: actions/upload-artifact@v2.2.3 with: name: Azure Functions Package @@ -69,20 +69,20 @@ jobs: #Web App Build - name: Restore dependencies for Web App - if: ${{env.TOGGLE_BUILD_WEBAPP==true}} + if: ${{env.AdsOpts_CI_BuildWebApp=="True"}} run: dotnet restore working-directory: ./solution/WebApplication - name: Publish Web App - if: ${{env.TOGGLE_BUILD_WEBAPP==true}} + if: ${{env.AdsOpts_CI_BuildWebApp=="True"}} run: dotnet publish --no-restore --configuration Release --output './deploy' working-directory: ./solution/WebApplication - run: echo "starting Zip" - name: zip web app - if: ${{env.TOGGLE_BUILD_WEBAPP==true}} + if: ${{env.AdsOpts_CI_BuildWebApp=="True"}} run: zip -r ../publish.zip * working-directory: ./solution/WebApplication/deploy - name: Package Web App - if: ${{env.TOGGLE_BUILD_WEBAPP==true}} + if: ${{env.AdsOpts_CI_BuilWebApp=="True"}} uses: actions/upload-artifact@v2.2.3 with: name: Web App Package @@ -90,8 +90,8 @@ jobs: - name: Set Env Variable Test shell: pwsh - run: echo "action_state=yellow" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + run: echo "AdsOpts_CD_Location=yellow" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append - name: test env variable - run: echo "${{ env.action_state }}" # This will output 'yellow' + run: echo "${{ env.AdsOpts_CD_Location }}" # This will output 'yellow' diff --git a/solution/Deployment/PushEnvFileIntoVariables.ps1 b/solution/Deployment/PushEnvFileIntoVariables.ps1 index 2343548e..7114e717 100644 --- a/solution/Deployment/PushEnvFileIntoVariables.ps1 +++ b/solution/Deployment/PushEnvFileIntoVariables.ps1 @@ -15,8 +15,11 @@ function ParseEnvFragment([string]$Json, [string]$NamePrefix) $Value = $p.Value if($p.TypeNameOfValue -ne "System.Management.Automation.PSCustomObject") { + #Push Variables to the GitHub Actions Compatible Store Write-Host "Writing $Name to env file" echo "$Name=$Value" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + #Also Push Variables to the Session Env Variables for local testing + [Environment]::SetEnvironmentVariable($Name, "$Value") } else { Write-Host "Further Parsing of $Name required" @@ -36,4 +39,7 @@ function ParseEnvFile ($EnvFile) $Json = Get-Content -Path "./environments/$($EnvFile).json" | Out-String ParseEnvFragment -Json $Json -NamePrefix "" + + + } diff --git a/solution/Deployment/environments/development.json b/solution/Deployment/environments/development.json index 044dafb3..d5592cd6 100644 --- a/solution/Deployment/environments/development.json +++ b/solution/Deployment/environments/development.json @@ -1,40 +1,37 @@ -{ - "AdsOpts": - { - "Location":"australiaeast", - "ServiceNames": - { - "Subscription" : "Jorampon Internal Consumption", - "ResourceGroupName" : "AdsTest", - "AADUser":"jorampon@microsoft.com", - "ServicePrincipal_Deployment":"AdsGoFastDeploymentSP", - "ServicePrincipalNameAFDownstream":"AdsGoFastDeployTestSP", - "ServicePrincipalNameWebAuth":"adsgofastwebappauth", - "ServicePrincipalNameAFAuth":"adsgofastwebappauth" +{ + "AdsOpts": { + "CI": { + "BuildFunctionApp": false, + "BuildWebApp": false, + "BuildAdsGoFastDatabase": false }, - "FolderPaths": - { - "ArmTemplates":"./arm" - }, - - "AzureLoginOptions": - { - "UseInteractiveAzCliLogin":true - }, - - "EnviroInstalls": - { - "PerformLocalInstalls":true, - "PerformLocalInstallsAzCli":false, - "PerformLocalInstallsAzCliAddToPath":true - }, - "ArmOptions": - { - "PerformDeployment":false, - "PerformDeploymentStorageLogging":false, - "PerformDeploymentAppService":false + "CD": { + "Location": "australiaeast", + "ServiceNames": { + "Subscription": "Jorampon Internal Consumption", + "ResourceGroupName": "AdsTest", + "AADUser": "jorampon@microsoft.com", + "ServicePrincipal_Deployment": "AdsGoFastDeploymentSP", + "ServicePrincipalNameAFDownstream": "AdsGoFastDeployTestSP", + "ServicePrincipalNameWebAuth": "adsgofastwebappauth", + "ServicePrincipalNameAFAuth": "adsgofastwebappauth" + }, + "FolderPaths": { + "ArmTemplates": "./arm" + }, + "AzureLoginOptions": { + "UseInteractiveAzCliLogin": true + }, + "EnviroInstalls": { + "PerformLocalInstalls": true, + "PerformLocalInstallsAzCli": false, + "PerformLocalInstallsAzCliAddToPath": true + }, + "ArmOptions": { + "PerformDeployment": false, + "PerformDeploymentStorageLogging": false, + "PerformDeploymentAppService": false + } } } -} - - +} \ No newline at end of file diff --git a/solution/Deployment/tbd.txt b/solution/Deployment/tbd.txt index 5e0e0e41..785d657f 100644 --- a/solution/Deployment/tbd.txt +++ b/solution/Deployment/tbd.txt @@ -30,3 +30,79 @@ AdsOpts_EnviroInstalls_PerformLocalInstallsAzCliAddToPath=True AdsOpts_ArmOptions_PerformDeployment=False AdsOpts_ArmOptions_PerformDeploymentStorageLogging=False AdsOpts_ArmOptions_PerformDeploymentAppService=False +AdsOpts_CI_BuildFunctionApp=False +AdsOpts_CI_BuildWebApp=False +AdsOpts_CI_BuildAdsGoFastDatabase=False +AdsOpts_CD_Location=australiaeast +AdsOpts_CD_ServiceNames_Subscription=Jorampon Internal Consumption +AdsOpts_CD_ServiceNames_ResourceGroupName=AdsTest +AdsOpts_CD_ServiceNames_AADUser=jorampon@microsoft.com +AdsOpts_CD_ServiceNames_ServicePrincipal_Deployment=AdsGoFastDeploymentSP +AdsOpts_CD_ServiceNames_ServicePrincipalNameAFDownstream=AdsGoFastDeployTestSP +AdsOpts_CD_ServiceNames_ServicePrincipalNameWebAuth=adsgofastwebappauth +AdsOpts_CD_ServiceNames_ServicePrincipalNameAFAuth=adsgofastwebappauth +AdsOpts_CD_FolderPaths_ArmTemplates=./arm +AdsOpts_CD_AzureLoginOptions_UseInteractiveAzCliLogin=True +AdsOpts_CD_EnviroInstalls_PerformLocalInstalls=True +AdsOpts_CD_EnviroInstalls_PerformLocalInstallsAzCli=False +AdsOpts_CD_EnviroInstalls_PerformLocalInstallsAzCliAddToPath=True +AdsOpts_CD_ArmOptions_PerformDeployment=False +AdsOpts_CD_ArmOptions_PerformDeploymentStorageLogging=False +AdsOpts_CD_ArmOptions_PerformDeploymentAppService=False +AdsOpts_CI_BuildFunctionApp=False +AdsOpts_CI_BuildWebApp=False +AdsOpts_CI_BuildAdsGoFastDatabase=False +AdsOpts_CD_Location=australiaeast +AdsOpts_CD_ServiceNames_Subscription=Jorampon Internal Consumption +AdsOpts_CD_ServiceNames_ResourceGroupName=AdsTest +AdsOpts_CD_ServiceNames_AADUser=jorampon@microsoft.com +AdsOpts_CD_ServiceNames_ServicePrincipal_Deployment=AdsGoFastDeploymentSP +AdsOpts_CD_ServiceNames_ServicePrincipalNameAFDownstream=AdsGoFastDeployTestSP +AdsOpts_CD_ServiceNames_ServicePrincipalNameWebAuth=adsgofastwebappauth +AdsOpts_CD_ServiceNames_ServicePrincipalNameAFAuth=adsgofastwebappauth +AdsOpts_CD_FolderPaths_ArmTemplates=./arm +AdsOpts_CD_AzureLoginOptions_UseInteractiveAzCliLogin=True +AdsOpts_CD_EnviroInstalls_PerformLocalInstalls=True +AdsOpts_CD_EnviroInstalls_PerformLocalInstallsAzCli=False +AdsOpts_CD_EnviroInstalls_PerformLocalInstallsAzCliAddToPath=True +AdsOpts_CD_ArmOptions_PerformDeployment=False +AdsOpts_CD_ArmOptions_PerformDeploymentStorageLogging=False +AdsOpts_CD_ArmOptions_PerformDeploymentAppService=False +AdsOpts_CI_BuildFunctionApp=False +AdsOpts_CI_BuildWebApp=False +AdsOpts_CI_BuildAdsGoFastDatabase=False +AdsOpts_CD_Location=australiaeast +AdsOpts_CD_ServiceNames_Subscription=Jorampon Internal Consumption +AdsOpts_CD_ServiceNames_ResourceGroupName=AdsTest +AdsOpts_CD_ServiceNames_AADUser=jorampon@microsoft.com +AdsOpts_CD_ServiceNames_ServicePrincipal_Deployment=AdsGoFastDeploymentSP +AdsOpts_CD_ServiceNames_ServicePrincipalNameAFDownstream=AdsGoFastDeployTestSP +AdsOpts_CD_ServiceNames_ServicePrincipalNameWebAuth=adsgofastwebappauth +AdsOpts_CD_ServiceNames_ServicePrincipalNameAFAuth=adsgofastwebappauth +AdsOpts_CD_FolderPaths_ArmTemplates=./arm +AdsOpts_CD_AzureLoginOptions_UseInteractiveAzCliLogin=True +AdsOpts_CD_EnviroInstalls_PerformLocalInstalls=True +AdsOpts_CD_EnviroInstalls_PerformLocalInstallsAzCli=False +AdsOpts_CD_EnviroInstalls_PerformLocalInstallsAzCliAddToPath=True +AdsOpts_CD_ArmOptions_PerformDeployment=False +AdsOpts_CD_ArmOptions_PerformDeploymentStorageLogging=False +AdsOpts_CD_ArmOptions_PerformDeploymentAppService=False +AdsOpts_CI_BuildFunctionApp=False +AdsOpts_CI_BuildWebApp=False +AdsOpts_CI_BuildAdsGoFastDatabase=False +AdsOpts_CD_Location=australiaeast +AdsOpts_CD_ServiceNames_Subscription=Jorampon Internal Consumption +AdsOpts_CD_ServiceNames_ResourceGroupName=AdsTest +AdsOpts_CD_ServiceNames_AADUser=jorampon@microsoft.com +AdsOpts_CD_ServiceNames_ServicePrincipal_Deployment=AdsGoFastDeploymentSP +AdsOpts_CD_ServiceNames_ServicePrincipalNameAFDownstream=AdsGoFastDeployTestSP +AdsOpts_CD_ServiceNames_ServicePrincipalNameWebAuth=adsgofastwebappauth +AdsOpts_CD_ServiceNames_ServicePrincipalNameAFAuth=adsgofastwebappauth +AdsOpts_CD_FolderPaths_ArmTemplates=./arm +AdsOpts_CD_AzureLoginOptions_UseInteractiveAzCliLogin=True +AdsOpts_CD_EnviroInstalls_PerformLocalInstalls=True +AdsOpts_CD_EnviroInstalls_PerformLocalInstallsAzCli=False +AdsOpts_CD_EnviroInstalls_PerformLocalInstallsAzCliAddToPath=True +AdsOpts_CD_ArmOptions_PerformDeployment=False +AdsOpts_CD_ArmOptions_PerformDeploymentStorageLogging=False +AdsOpts_CD_ArmOptions_PerformDeploymentAppService=False