Skip to content

Commit

Permalink
FGT: gha cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jvhoof committed Sep 20, 2024
1 parent 2f08a5a commit 6c77e2d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
39 changes: 28 additions & 11 deletions .github/workflows/fgt-azure-marketplace-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,43 @@ jobs:
$marketplaceVersionsUI_arm64 = @()
$marketplaceVersions_x64 = @("latest") + $(Get-LatestVersions $(Get-AzVMImage -PublisherName "${env:PUBLISHER}" -Location eastus -Offer "${env:PRODUCTOFFER}" -sku "${env:PRODUCTSKU_X64}").Version)
$marketplaceVersions_x64 | ConvertTo-Json | Out-File -Filepath "./fgtversion_x64.json"
$marketplaceVersions_x64 | ForEach-Object { $marketplaceVersionsUI_x64 += [pscustomobject]@{label=$_;value=$_} }
$marketplaceVersionsUI_x64 | ConvertTo-Json | Out-File -Filepath "./fgtversion_ui_x64.json"
$marketplaceVersions_arm64 = @("latest") + $(Get-LatestVersions $(Get-AzVMImage -PublisherName "${env:PUBLISHER}" -Location eastus -Offer "${env:PRODUCTOFFER}" -sku "${env:PRODUCTSKU_ARM64}").Version)
$marketplaceVersions_arm64 | ConvertTo-Json | Out-File -Filepath "./fgtversion_arm64.json"
$marketplaceVersions_arm64 | ForEach-Object { $marketplaceVersionsUI_arm64 += [pscustomobject]@{label=$_;value=$_} }
$marketplaceVersionsUI_arm64 | ConvertTo-Json | Out-File -Filepath "./fgtversion_ui_arm64.json"
foreach ($buildingBlock in $buildingBlocks) {
$dest = "./releases/${buildingBlock}/"
[void](New-Item -Path "${dest}" -Type Directory)
$content = Get-Content -Raw -Path "./FortiGate/${buildingBlock}/azuredeploy.json" | ConvertFrom-Json
$content.parameters.fortiGateImageVersion.allowedValues = $marketplaceVersions_x64
$content.resources.Where({$_.type -eq 'Microsoft.Resources/deployments'})[0].name = "pid-776b2227-2743-485a-b385-e9dfd42bfe75-partnercenter"
$content | ConvertTo-Json -depth 100 | Out-File "${dest}/mainTemplate.json"
"" | Out-File -Append "${dest}/mainTemplate.json"
$content = Get-Content -Raw -Path "./FortiGate/${buildingBlock}/createUiDefinition.json" | ConvertFrom-Json
$content.parameters.basics.Where({$_.Name.equals("fortiGateImageVersion")}).constraints.allowedValues = $marketplaceVersionsUI_x64
$content | ConvertTo-Json -depth 100 | Out-File "${dest}/createUiDefinition.json"
"" | Out-File -Append "${dest}/createUiDefinition.json"
if (Test-Path -Path "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json" -PathType Leaf) {
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json" | jq --slurpfile content "./fgtversion_x64.json" '.parameters.fortiGateImageVersion_x64.allowedValues = $content[]' | Set-Content -Path "./releases/${buildingBlock}/mainTemplate.json"
$content = Get-Content "./releases/${buildingBlock}/mainTemplate.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./releases/${buildingBlock}/mainTemplate.json"
}
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json" | jq --slurpfile content "./fgtversion_arm64.json" '.parameters.fortiGateImageVersion_arm64.allowedValues = $content[]' | Set-Content -Path "./releases/${buildingBlock}/mainTemplate.json"
$content = Get-Content "./releases/${buildingBlock}/mainTemplate.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./releases/${buildingBlock}/mainTemplate.json"
}
}
if (Test-Path -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" -PathType Leaf) {
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" | jq --slurpfile content "./fgtversion_ui_x64.json" '(.parameters.steps[].elements[] | select( .name == "instancetype_x64") | .elements[] | select( .name == "fortiGateImageVersion_x64") | .constraints.allowedValues) |= $content[]' | Set-Content -Path "./releases/${buildingBlock}/createUiDefinition.json"
$content = Get-Content "./releases/${buildingBlock}/createUiDefinition.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./releases/${buildingBlock}/createUiDefinition.json"
}
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" | jq --slurpfile content "./fgtversion_ui_arm64.json" '(.parameters.steps[].elements[] | select( .name == "instancetype_arm64") | .elements[] | select( .name == "fortiGateImageVersion_arm64") | .constraints.allowedValues) |= $content[]' | Set-Content -Path "./releases/${buildingBlock}/createUiDefinition.json"
$content = Get-Content "./releases/${buildingBlock}/createUiDefinition.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./releases/${buildingBlock}/createUiDefinition.json"
}
}
Compress-Archive -Path "./releases/${buildingBlock}/*" -DestinationPath "./releases/${env:PRODUCTL}-$($buildingBlock.ToLower())-azure-templates.zip"
}
azPSVersion: "latest"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/fgt-azure-marketplace-version-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ jobs:
$marketplaceVersionsUI_x64 | ConvertTo-Json | Out-File -Filepath "./fgtversionui_x64.json"
$marketplaceVersions_arm64 = @("latest") + $(Sort-Versions($(Get-AzVMImage -PublisherName "fortinet" -Location eastus -Offer "${env:PRODUCTOFFER}" -sku "${env:PRODUCTSKU_ARM64}").Version))
$marketplaceVersions_arm64 += "latest"
[array]::Reverse($marketplaceVersions_arm64)
$marketplaceVersions_arm64 | ConvertTo-Json | Out-File -Filepath "./fgtversion_arm64.json"
$marketplaceVersions_arm64 | ForEach-Object { $marketplaceVersionsUI_arm64 += [pscustomobject]@{label=$_;value=$_} }
$marketplaceVersionsUI_arm64 | ConvertTo-Json | Out-File -Filepath "./fgtversion_arm64_ui.json"
Expand Down

0 comments on commit 6c77e2d

Please sign in to comment.