Skip to content

[FGT] Azure Marketplace version update #166

[FGT] Azure Marketplace version update

[FGT] Azure Marketplace version update #166

name: '[FGT] Azure Marketplace version update'
on:
workflow_dispatch:
schedule:
- cron: '00 22 * * 0'
env:
PRODUCT: FortiGate
PRODUCTSHORT: FGT
PRODUCTOFFER: fortinet_fortigate-vm_v5
PRODUCTSKU_X64: fortinet_fg-vm
PRODUCTSKU_ARM64: fortinet_fg-vm_arm64
jobs:
ARM-FGT-Version-Update:
name: Update FGT version list
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Azure Login via Az module
uses: azure/login@v2
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
enable-AzPSSession: true
- name: Verify FGT published version, update templates when new version found
uses: azure/powershell@v2
with:
inlineScript: |
function Sort-Versions {
param (
[string[]]$Versions
)
$parsedVersions = $Versions | ForEach-Object {
$versionParts = $_ -split '\.'
[pscustomobject]@{
Major = [int]$versionParts[0]
Minor = [int]$versionParts[1]
Patch = [int]$versionParts[2]
FullVersion = $_
}
}
$sortedVersions = $parsedVersions | Sort-Object -Property Major, Minor, Patch -Descending
$sortedVersions.FullVersion
}
$buildingBlocks = @("A-Single-VM", "Active-Active-ELB-ILB","Active-Passive-ELB-ILB","Active-Passive-SDN")
$marketplaceVersions_x64 = @()
$marketplaceVersionsUI_x64 = @()
$marketplaceVersions_arm64 = @()
$marketplaceVersionsUI_arm64 = @()
$marketplaceVersions_x64 = @("latest") + $(Sort-Versions($(Get-AzVMImage -PublisherName "fortinet" -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 "./fgtversionui_x64.json"
$marketplaceVersions_arm64 = @("latest") + $(Sort-Versions($(Get-AzVMImage -PublisherName "fortinet" -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_arm64_ui.json"
foreach ($buildingBlock in $buildingBlocks) {
if (Test-Path -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" -PathType Leaf) {
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" | jq --slurpfile content "./fgtversion_x64.json" '.parameters.fortiGateImageVersion_x64.allowedValues = $content[]' | Set-Content -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json"
}
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" | jq --slurpfile content "./fgtversion_arm64.json" '.parameters.fortiGateImageVersion_arm64.allowedValues = $content[]' | Set-Content -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/mainTemplate.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 "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json"
}
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json" | jq --slurpfile content "./fgtversion_arm64.json" '.parameters.fortiGateImageVersion_arm64.allowedValues = $content[]' | Set-Content -Path "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json"
}
}
if (Test-Path -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" -PathType Leaf) {
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" | jq --slurpfile content "./fgtversionui_x64.json" '(.parameters.steps[].elements[] | select( .name == "instancetype_x64") | .elements[] | select( .name == "fortiGateImageVersion_x64") | .constraints.allowedValues) |= $content[]' | Set-Content -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json"
}
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" | jq --slurpfile content "./fgtversion_arm64_ui.json" '(.parameters.steps[].elements[] | select( .name == "instancetype_arm64") | .elements[] | select( .name == "fortiGateImageVersion_arm64") | .constraints.allowedValues) |= $content[]' | Set-Content -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json"
}
}
}
$buildingBlocks = @("AzureApplicationGateway/scenario1","AzureApplicationGateway/scenario2","AzureApplicationGateway/scenario3","AzureGatewayLoadBalancer","AzureRouteServer/Active-Passive","ZTNAApplicationGateway")
foreach ($buildingBlock in $buildingBlocks) {
if (Test-Path -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" -PathType Leaf) {
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" | jq --slurpfile content "./fgtversion_x64.json" '.parameters.fortiGateImageVersion.allowedValues = $content[]' | Set-Content -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/mainTemplate.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.allowedValues = $content[]' | Set-Content -Path "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json"
}
}
if (Test-Path -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" -PathType Leaf) {
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" | jq --slurpfile content "./fgtversionui_x64.json" '(.parameters.basics[] | select( .name == "fortiGateImageVersion") | .constraints.allowedValues) |= $content[]' | Set-Content -Path "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json"
$content = Get-Content "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json"
}
}
}
Remove-Item "./fgtversion_x64.json"
Remove-Item "./fgtversionui_x64.json"
Remove-Item "./fgtversion_arm64.json"
Remove-Item "./fgtversion_arm64_ui.json"
azPSVersion: "latest"
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update report
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: fgt-vm-update-version
delete-branch: true
title: '[FGT] Azure Marketplace FGT Version update'
body: |
Update report
- Updated FGT version in building blocks: "A-Single-VM", "Active-Active-ELB-ILB","Active-Passive-ELB-ILB","Active-Passive-SDN"
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: |
report
automated pr
assignees: jvhoof
reviewers: jvhoof
draft: false