Skip to content

Commit

Permalink
Made GH workflows repo/branch agnostic + added changes following PR r…
Browse files Browse the repository at this point in the history
…eview
  • Loading branch information
Helder Pinto committed May 24, 2024
1 parent 2d84b6b commit ab291ea
Show file tree
Hide file tree
Showing 113 changed files with 19,368 additions and 710 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/aoe-cd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
AOE_WORKSPACENAME: ${{ secrets.AOE_WORKSPACENAME }}
AOE_WORKSPACERG: ${{ secrets.AOE_WORKSPACERG }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref.name }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
shell: pwsh
run: |
Expand Down Expand Up @@ -57,5 +57,5 @@ jobs:
shell: pwsh
run: |
Set-Location ./src/optimization-engine
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json -TemplateUri "https://raw.githubusercontent.com/microsoft/finops-toolkit/dev/src/optimization-engine/azuredeploy.bicep"
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json -TemplateUri "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref.name }}/src/optimization-engine/azuredeploy.bicep"
- run: echo "🍏 This job's status is ${{ job.status }}."
4 changes: 2 additions & 2 deletions .github/workflows/aoe-cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
AOE_LOCATION: ${{ secrets.AOE_LOCATION }}
AOE_NAMEPREFIX: ${{ secrets.AOE_NAMEPREFIX }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref.name }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
shell: pwsh
run: |
Expand Down Expand Up @@ -55,5 +55,5 @@ jobs:
shell: pwsh
run: |
Set-Location ./src/optimization-engine
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json -TemplateUri "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref.name }}/src/optimization-engine/azuredeploy.bicep"
- run: echo "🍏 This job's status is ${{ job.status }}."
4 changes: 2 additions & 2 deletions .github/workflows/aoe-cd-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
AOE_LOCATION: ${{ secrets.AOE_LOCATION }}
AOE_NAMEPREFIX: ${{ secrets.AOE_NAMEPREFIX }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref.name }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
shell: pwsh
run: |
Expand Down Expand Up @@ -55,5 +55,5 @@ jobs:
shell: pwsh
run: |
Set-Location ./src/optimization-engine
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json -TemplateUri "https://raw.githubusercontent.com/microsoft/finops-toolkit/features/aoe/src/optimization-engine/azuredeploy.bicep"
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json -TemplateUri "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref.name }}/src/optimization-engine/azuredeploy.bicep"
- run: echo "🍏 This job's status is ${{ job.status }}."
24 changes: 12 additions & 12 deletions docs/deploy/finops-hub-0.2.1-rc.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "13980213354947249584"
"version": "0.24.24.22086",
"templateHash": "6371350577264419703"
}
},
"parameters": {
Expand Down Expand Up @@ -91,8 +91,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "3688631684062478281"
"version": "0.24.24.22086",
"templateHash": "2610829918662778812"
}
},
"parameters": {
Expand Down Expand Up @@ -162,7 +162,7 @@
"dataFactorySuffix": "[format('-{0}', variables('uniqueSuffix'))]",
"dataFactoryName": "[replace(format('{0}{1}', take(variables('dataFactoryPrefix'), sub(63, length(variables('dataFactorySuffix')))), variables('dataFactorySuffix')), '--', '-')]",
"telemetryId": "00f120b5-2007-6120-0000-40b000000000",
"finOpsToolkitVersion": "0.2.1-rc.2"
"finOpsToolkitVersion": "placeholder"
},
"resources": [
{
Expand Down Expand Up @@ -234,8 +234,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "3183312799881178788"
"version": "0.24.24.22086",
"templateHash": "9609675916139055971"
}
},
"parameters": {
Expand Down Expand Up @@ -291,7 +291,7 @@
}
},
"variables": {
"$fxv#0": "0.2.1-rc.2",
"$fxv#0": "placeholder",
"$fxv#1": "# Copyright (c) Microsoft Corporation.\r\n# Licensed under the MIT License.\r\n\r\nWrite-Output \"Updating settings.json file...\"\r\nWrite-Output \" Storage account: $env:storageAccountName\"\r\nWrite-Output \" Container: $env:containerName\"\r\n\r\n$validateScopes = { $_.Length -gt 45 }\r\n\r\n# Initialize variables\r\n$fileName = 'settings.json'\r\n$filePath = Join-Path -Path . -ChildPath $fileName\r\n$newScopes = $env:exportScopes.Split('|') | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }\r\n\r\n# Get storage context\r\n$storageContext = @{\r\n Context = New-AzStorageContext -StorageAccountName $env:storageAccountName -UseConnectedAccount\r\n Container = $env:containerName\r\n}\r\n\r\n# Download existing settings, if they exist\r\n$blob = Get-AzStorageBlobContent @storageContext -Blob $fileName -Destination $filePath -Force\r\nif ($blob) {\r\n Write-Output \"Existing settings.json file found. Updating...\"\r\n $text = Get-Content $filePath -Raw\r\n Write-Output \"---------\"\r\n Write-Output $text\r\n Write-Output \"---------\"\r\n $json = $text | ConvertFrom-Json\r\n\r\n # Rename exportScopes to scopes + convert to object array\r\n if ($json.exportScopes) {\r\n Write-Output \" Updating exportScopes...\"\r\n if ($json.exportScopes[0] -is [string]) {\r\n Write-Output \" Converting string array to object array...\"\r\n $json.exportScopes = $json.exportScopes | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }\r\n if (-not ($json.exportScopes -is [array])) {\r\n Write-Output \" Converting single object to object array...\"\r\n $json.exportScopes = @($json.exportScopes)\r\n }\r\n }\r\n\r\n Write-Output \" Renaming to 'scopes'...\"\r\n $json | Add-Member -MemberType NoteProperty -Name scopes -Value $json.exportScopes\r\n $json.PSObject.Properties.Remove('exportScopes')\r\n }\r\n}\r\n\r\n# Set default if not found\r\nif (!$json) {\r\n Write-Output \"No existing settings.json file found. Creating new file...\"\r\n $json = [ordered]@{\r\n '$schema' = 'https://aka.ms/finops/hubs/settings-schema'\r\n type = 'HubInstance'\r\n version = ''\r\n learnMore = 'https://aka.ms/finops/hubs'\r\n scopes = @()\r\n }\r\n}\r\n\r\n# Updating settings\r\nWrite-Output \"Updating version to $env:ftkVersion...\"\r\n$json.version = $env:ftkVersion\r\nif ($newScopes) {\r\n Write-Output \"Merging $($newScopes.Count) scopes...\"\r\n $json.scopes = Compare-Object -ReferenceObject $json.scopes -DifferenceObject $newScopes -Property scope -PassThru -IncludeEqual\r\n\r\n # Remove the SideIndicator property from the Compare-Object output\r\n $json.scopes | ForEach-Object { $_.PSObject.Properties.Remove('SideIndicator') } | ConvertTo-Json\r\n\r\n if (-not ($json.scopes -is [array])) {\r\n $json.scopes = @($json.scopes)\r\n }\r\n Write-Output \"$($json.scopes.Count) scopes found.\"\r\n}\r\n$text = $json | ConvertTo-Json\r\nWrite-Output \"---------\"\r\nWrite-Output $text\r\nWrite-Output \"---------\"\r\n$text | Out-File $filePath\r\n\r\n# Upload new/updated settings\r\nWrite-Output \"Uploading settings.json file...\"\r\nSet-AzStorageBlobContent @storageContext -File $filePath -Force\r\n",
"safeHubName": "[replace(replace(toLower(parameters('hubName')), '-', ''), '_', '')]",
"storageAccountSuffix": "[parameters('uniqueSuffix')]",
Expand Down Expand Up @@ -515,8 +515,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "5687422994519942055"
"version": "0.24.24.22086",
"templateHash": "5738194981634133446"
}
},
"parameters": {
Expand Down Expand Up @@ -1829,8 +1829,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "8584269155107147116"
"version": "0.24.24.22086",
"templateHash": "10770478197596540923"
}
},
"parameters": {
Expand Down
24 changes: 12 additions & 12 deletions docs/deploy/finops-hub-latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "13980213354947249584"
"version": "0.24.24.22086",
"templateHash": "6371350577264419703"
}
},
"parameters": {
Expand Down Expand Up @@ -91,8 +91,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "3688631684062478281"
"version": "0.24.24.22086",
"templateHash": "2610829918662778812"
}
},
"parameters": {
Expand Down Expand Up @@ -162,7 +162,7 @@
"dataFactorySuffix": "[format('-{0}', variables('uniqueSuffix'))]",
"dataFactoryName": "[replace(format('{0}{1}', take(variables('dataFactoryPrefix'), sub(63, length(variables('dataFactorySuffix')))), variables('dataFactorySuffix')), '--', '-')]",
"telemetryId": "00f120b5-2007-6120-0000-40b000000000",
"finOpsToolkitVersion": "0.2.1-rc.2"
"finOpsToolkitVersion": "placeholder"
},
"resources": [
{
Expand Down Expand Up @@ -234,8 +234,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "3183312799881178788"
"version": "0.24.24.22086",
"templateHash": "9609675916139055971"
}
},
"parameters": {
Expand Down Expand Up @@ -291,7 +291,7 @@
}
},
"variables": {
"$fxv#0": "0.2.1-rc.2",
"$fxv#0": "placeholder",
"$fxv#1": "# Copyright (c) Microsoft Corporation.\r\n# Licensed under the MIT License.\r\n\r\nWrite-Output \"Updating settings.json file...\"\r\nWrite-Output \" Storage account: $env:storageAccountName\"\r\nWrite-Output \" Container: $env:containerName\"\r\n\r\n$validateScopes = { $_.Length -gt 45 }\r\n\r\n# Initialize variables\r\n$fileName = 'settings.json'\r\n$filePath = Join-Path -Path . -ChildPath $fileName\r\n$newScopes = $env:exportScopes.Split('|') | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }\r\n\r\n# Get storage context\r\n$storageContext = @{\r\n Context = New-AzStorageContext -StorageAccountName $env:storageAccountName -UseConnectedAccount\r\n Container = $env:containerName\r\n}\r\n\r\n# Download existing settings, if they exist\r\n$blob = Get-AzStorageBlobContent @storageContext -Blob $fileName -Destination $filePath -Force\r\nif ($blob) {\r\n Write-Output \"Existing settings.json file found. Updating...\"\r\n $text = Get-Content $filePath -Raw\r\n Write-Output \"---------\"\r\n Write-Output $text\r\n Write-Output \"---------\"\r\n $json = $text | ConvertFrom-Json\r\n\r\n # Rename exportScopes to scopes + convert to object array\r\n if ($json.exportScopes) {\r\n Write-Output \" Updating exportScopes...\"\r\n if ($json.exportScopes[0] -is [string]) {\r\n Write-Output \" Converting string array to object array...\"\r\n $json.exportScopes = $json.exportScopes | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }\r\n if (-not ($json.exportScopes -is [array])) {\r\n Write-Output \" Converting single object to object array...\"\r\n $json.exportScopes = @($json.exportScopes)\r\n }\r\n }\r\n\r\n Write-Output \" Renaming to 'scopes'...\"\r\n $json | Add-Member -MemberType NoteProperty -Name scopes -Value $json.exportScopes\r\n $json.PSObject.Properties.Remove('exportScopes')\r\n }\r\n}\r\n\r\n# Set default if not found\r\nif (!$json) {\r\n Write-Output \"No existing settings.json file found. Creating new file...\"\r\n $json = [ordered]@{\r\n '$schema' = 'https://aka.ms/finops/hubs/settings-schema'\r\n type = 'HubInstance'\r\n version = ''\r\n learnMore = 'https://aka.ms/finops/hubs'\r\n scopes = @()\r\n }\r\n}\r\n\r\n# Updating settings\r\nWrite-Output \"Updating version to $env:ftkVersion...\"\r\n$json.version = $env:ftkVersion\r\nif ($newScopes) {\r\n Write-Output \"Merging $($newScopes.Count) scopes...\"\r\n $json.scopes = Compare-Object -ReferenceObject $json.scopes -DifferenceObject $newScopes -Property scope -PassThru -IncludeEqual\r\n\r\n # Remove the SideIndicator property from the Compare-Object output\r\n $json.scopes | ForEach-Object { $_.PSObject.Properties.Remove('SideIndicator') } | ConvertTo-Json\r\n\r\n if (-not ($json.scopes -is [array])) {\r\n $json.scopes = @($json.scopes)\r\n }\r\n Write-Output \"$($json.scopes.Count) scopes found.\"\r\n}\r\n$text = $json | ConvertTo-Json\r\nWrite-Output \"---------\"\r\nWrite-Output $text\r\nWrite-Output \"---------\"\r\n$text | Out-File $filePath\r\n\r\n# Upload new/updated settings\r\nWrite-Output \"Uploading settings.json file...\"\r\nSet-AzStorageBlobContent @storageContext -File $filePath -Force\r\n",
"safeHubName": "[replace(replace(toLower(parameters('hubName')), '-', ''), '_', '')]",
"storageAccountSuffix": "[parameters('uniqueSuffix')]",
Expand Down Expand Up @@ -515,8 +515,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "5687422994519942055"
"version": "0.24.24.22086",
"templateHash": "5738194981634133446"
}
},
"parameters": {
Expand Down Expand Up @@ -1829,8 +1829,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "8584269155107147116"
"version": "0.24.24.22086",
"templateHash": "10770478197596540923"
}
},
"parameters": {
Expand Down
6 changes: 3 additions & 3 deletions docs/deploy/governance-workbook-0.2.1-rc.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "11237752380577820438"
"version": "0.24.24.22086",
"templateHash": "12278846045479855901"
}
},
"parameters": {
Expand Down Expand Up @@ -8035,7 +8035,7 @@
"workbookJson": "[string(variables('$fxv#0'))]",
"workbookId": "907",
"telemetryId": "[format('00f120b5-2007-6120-0000-{0}30126b006', variables('workbookId'))]",
"finOpsToolkitVersion": "0.2.1-rc.2"
"finOpsToolkitVersion": "placeholder"
},
"resources": [
{
Expand Down
6 changes: 3 additions & 3 deletions docs/deploy/governance-workbook-latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "11237752380577820438"
"version": "0.24.24.22086",
"templateHash": "12278846045479855901"
}
},
"parameters": {
Expand Down Expand Up @@ -8035,7 +8035,7 @@
"workbookJson": "[string(variables('$fxv#0'))]",
"workbookId": "907",
"telemetryId": "[format('00f120b5-2007-6120-0000-{0}30126b006', variables('workbookId'))]",
"finOpsToolkitVersion": "0.2.1-rc.2"
"finOpsToolkitVersion": "placeholder"
},
"resources": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ var csvExports = [
ingestTimeOffset: 'PT2H'
ingestFrequency: 'Hour'
ingestJobId: monitorIngestJobId
exportSchedule: null
exportJobId: 'dummy'
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ var csvExports = [
ingestTimeOffset: 'PT2H'
ingestFrequency: 'Hour'
ingestJobId: monitorIngestJobId
exportSchedule: null
exportJobId: 'dummy'
}
{
Expand Down
Loading

0 comments on commit ab291ea

Please sign in to comment.