Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Update dev pipeline for CaC solution version upgrade preserving attestations #127

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions .github/workflows/deploy_dev_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ jobs:
run: |
$moduleCodeFilesObjs = Get-ChildItem -Path .\src -Recurse -Include *.psm1 -Exclude '*-GSA*','*GuardrailsSolutionAcceleratorSetup*','*Deploy-GuardrailsSolutionAccelerator*'
Write-Host "'$($moduleCodeFilesObjs.count)' module manifest files "

ForEach ($moduleCodeFile in $moduleCodeFilesObjs) {
$moduleManifestFile = Get-Item -Path $moduleCodeFile.FullName.replace('psm1','psd1')

If ($moduleCodeFilesObjs.FullName -icontains $moduleCodeFile.FullName -or $moduleCodeFilesObjs.FullName -icontains $moduleManifestFile.FullName) {
Write-Host "Module '$($moduleCodeFile.BaseName)' found, zipping module files..."

$destPath = "./psmodules/$($moduleCodeFile.BaseName).zip"
If ($moduleCodeFile.DIrectory.Name -eq 'Guardrails-Localization') {
Compress-Archive -Path "$($moduleCodeFile.Directory)/*" -DestinationPath $destPath -Force
Expand Down Expand Up @@ -106,8 +108,9 @@ jobs:
PIPELINEMODULESTAGING_RGNAME: ${{ vars.PIPELINEMODULESTAGING_RGNAME }}
PIPELINEMODULESTAGING_STORAGEACCOUNTNAME: ${{ vars.PIPELINEMODULESTAGING_SANAME_DEV }}
DEVSUBSCRIPTION_ID: ${{ secrets.DEV_AZURE_SUBSCRIPTION_ID}}

- name: Pre-Clean Dev environment
if: ${{ env.DEV_UPGRADE_VAR != 'true'}}
uses: azure/powershell@v1
continue-on-error: true
with:
Expand All @@ -128,6 +131,8 @@ jobs:
$DEVLAW_SEC = $env:DEVLAW_SEC
$DEVLAW_HEALTH = $env:DEVLAW_HEALTH

$DEV_UPGRADE_VAR = $env:DEV_UPGRADE_VAR

$configContent = @"
{
"keyVaultName": "kvcac",
Expand Down Expand Up @@ -157,6 +162,7 @@ jobs:
}
"@
Set-Content -Path $configFilePath -Value $configContent

Push-Location -Path setup

try {
Expand Down Expand Up @@ -187,6 +193,8 @@ jobs:
LOCATIONPOLICY_ID: ${{ vars.LOCATIONPOLICY_ID }}
DEVLAW_SEC: ${{ vars.DEVLAW_SEC }}
DEVLAW_HEALTH: ${{ vars.DEVLAW_HEALTH }}
DEV_UPGRADE_VAR: ${{ vars.DEV_UPGRADE_VAR}}

- name: Relogin AZ
uses: azure/login@v1
with:
Expand All @@ -213,6 +221,8 @@ jobs:
$DEVLAW_SEC = $env:DEVLAW_SEC
$DEVLAW_HEALTH = $env:DEVLAW_HEALTH

$DEV_UPGRADE_VAR = $env:DEV_UPGRADE_VAR

$configContent = @"
{
"keyVaultName": "kvcac",
Expand Down Expand Up @@ -246,28 +256,44 @@ jobs:
# Load tags JSON content into a variable
$setupFileRelativePath = "setup/tags.json"
$setupFullPath = Join-Path $env:GITHUB_WORKSPACE $setupFileRelativePath

$jsonContent = Get-Content -Raw -Path $setupFullPath | ConvertFrom-Json

# Add additional tags for dev tenant
$jsonContent | Add-Member -Type NoteProperty -Name 'ClientOrganization' -Value 'SSC'
$jsonContent | Add-Member -Type NoteProperty -Name 'CostCenter' -Value 'SSC Cloud Operations'
$jsonContent | Add-Member -Type NoteProperty -Name 'DataSensitivity' -Value 'PB'
$jsonContent | Add-Member -Type NoteProperty -Name 'ProjectContact' -Value 'Amrinder'
$jsonContent | Add-Member -Type NoteProperty -Name 'ProjectName' -Value 'ComplianceAsCodeAzure'
$jsonContent | Add-Member -Type NoteProperty -Name 'TechnicalContact' -Value 'Amrinder'

# Save the modified content back to the tags JSON file
$jsonContent | ConvertTo-Json | Set-Content -Path $setupFullPath

$storageContext = (Get-AzStorageAccount -ResourceGroupName $env:PIPELINEMODULESTAGING_RGNAME -Name $env:PIPELINEMODULESTAGING_STORAGEACCOUNTNAME).context
$modulesStagingURI = $storageContext.BlobEndpoint.ToString() + 'psmodules'

$alternatePSModulesURL = $modulesStagingURI
Write-Output "alternatePSModulesURL is '$alternatePSModulesURL'"

$optionalParams = @{}
if ($alternatePSModulesURL) {
$optionalParams['alternatePSModulesURL'] = $alternatePSModulesURL
}

try {
$ErrorActionPreference = 'Stop'
ipmo ./src/GuardrailsSolutionAcceleratorSetup
Deploy-GuardrailsSolutionAccelerator -configFilePath $configFilePath -newComponents CoreComponents, CentralizedCustomerDefenderForCloudSupport, CentralizedCustomerReportingSupport -Yes @optionalParams -verbose
if ($DEV_UPGRADE_VAR -eq "true"){
Write-Output "Upgrade workflow flag is set to '$DEV_UPGRADE_VAR'"
Write-Output "Upgrading the CaC solution"
Deploy-GuardrailsSolutionAccelerator -configFilePath $configFilePath -update -Yes @optionalParams -verbose
}
else {
Write-Output "Upgrade workflow flag is set to '$DEV_UPGRADE_VAR'"
Write-Output "Deploying a new installation of the CaC solution"
Deploy-GuardrailsSolutionAccelerator -configFilePath $configFilePath -newComponents CoreComponents, CentralizedCustomerDefenderForCloudSupport, CentralizedCustomerReportingSupport -Yes @optionalParams -verbose
}
}
catch {
throw "Failed test deploy of solution with error: $_"
Expand All @@ -292,6 +318,7 @@ jobs:
LOCATIONPOLICY_ID: ${{ vars.LOCATIONPOLICY_ID }}
DEVLAW_SEC: ${{ vars.DEVLAW_SEC }}
DEVLAW_HEALTH: ${{ vars.DEVLAW_HEALTH }}
DEV_UPGRADE_VAR: ${{ vars.DEV_UPGRADE_VAR}}

- name: Check for AA Job Errors
uses: azure/powershell@v1
Expand Down
Loading