Skip to content

[FGT] Azure Marketplace version update #144

[FGT] Azure Marketplace version update

[FGT] Azure Marketplace version update #144

name: '[FGT] Azure Marketplace version update'
on:
workflow_dispatch:
schedule:
- cron: '00 22 * * 0'
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: |
$buildingBlocks = @("A-Single-VM", "Active-Active-ELB-ILB","Active-Passive-ELB-ILB","Active-Passive-SDN","AzureApplicationGateway/scenario1","AzureApplicationGateway/scenario2","AzureApplicationGateway/scenario3","AzureGatewayLoadBalancer","AzureRouteServer/Active-Passive","ZTNAApplicationGateway")
$fgtMarketplaceVersions = @()
$fgtMarketplaceVersionsUI = @()
$fortigateVersions = Get-AzVMImage -PublisherName "fortinet" -Location eastus -Offer "fortinet_fortigate-vm_v5" -sku "fortinet_fg-vm"
$fgtMarketplaceVersions += $($fortigateVersions).Version
$fgtMarketplaceVersions += "latest"
$fgtMarketplaceVersions | ConvertTo-Json | Out-File -Filepath "./fgtversion.json"
$fgtMarketplaceVersions | ForEach-Object { $fgtMarketplaceVersionsUI += [pscustomobject]@{label=$_;value=$_} }
$fgtMarketplaceVersionsUI | ConvertTo-Json | Out-File -Filepath "./fgtversionui.json"
foreach ($buildingBlock in $buildingBlocks) {
if (Test-Path -Path "./FortiGate/${buildingBlock}/mainTemplate.json" -PathType Leaf) {
Get-Content -Raw -Path "./FortiGate/${buildingBlock}/mainTemplate.json" | jq --slurpfile content "./fgtversion.json" '.parameters.fortiGateImageVersion.allowedValues = $content[]' | Set-Content -Path "./FortiGate/${buildingBlock}/mainTemplate.json"
$content = Get-Content "./FortiGate/${buildingBlock}/mainTemplate.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./FortiGate/${buildingBlock}/mainTemplate.json"
}
}
if (Test-Path -Path "./FortiGate/${buildingBlock}/azuredeploy.json" -PathType Leaf) {
Get-Content -Raw -Path "./FortiGate/${buildingBlock}/azuredeploy.json" | jq --slurpfile content "./fgtversion.json" '.parameters.fortiGateImageVersion.allowedValues = $content[]' | Set-Content -Path "./FortiGate/${buildingBlock}/azuredeploy.json"
$content = Get-Content "./FortiGate/${buildingBlock}/azuredeploy.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./FortiGate/${buildingBlock}/azuredeploy.json"
}
}
if (Test-Path -Path "./FortiGate/${buildingBlock}/createUiDefinition.json" -PathType Leaf) {
Get-Content -Raw -Path "./FortiGate/${buildingBlock}/createUiDefinition.json" | jq --slurpfile content "./fgtversionui.json" '(.parameters.basics[] | select( .name == "fortiGateImageVersion") | .constraints.allowedValues) |= $content[]' | Set-Content -Path "./FortiGate/${buildingBlock}/createUiDefinition.json"
$content = Get-Content "./FortiGate/${buildingBlock}/createUiDefinition.json" -Raw
if (-Not $content -match '(?<=\r\n)\z') {
"" | Out-File -Append "./FortiGate/${buildingBlock}/createUiDefinition.json"
}
}
}
Remove-Item "./fgtversion.json"
Remove-Item "./fgtversionui.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 <noreply@github.com>
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