[FMG] Azure Marketplace version update #74
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: '[FMG] Azure Marketplace version update' | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '00 22 * * 0' | |
env: | |
PRODUCT: FortiManager | |
PRODUCTSHORT: FMG | |
jobs: | |
ARM-FMG-Version-Update: | |
name: Update FMG 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 FMG published version, update templates when new version found | |
uses: azure/powershell@v2 | |
with: | |
inlineScript: | | |
$buildingBlocks = @("single", "ha") | |
$versions = @() | |
$versionsui = @() | |
$versions = $(Get-AzVMImage -PublisherName "fortinet" -Location eastus -Offer "fortinet-fortimanager" -sku "fortinet-fortimanager").Version | |
$versions += "latest" | |
$versions | ConvertTo-Json | Out-File -Filepath "./fmgversion.json" | |
$versions | ForEach-Object { $versionsui += [pscustomobject]@{label=$_;value=$_} } | |
$versionsui | ConvertTo-Json | Out-File -Filepath "./fmgversionui.json" | |
foreach ($buildingBlock in $buildingBlocks) { | |
Get-Content -Raw -Path "./FortiManager/${buildingBlock}/mainTemplate.json" | jq --slurpfile content "./fmgversion.json" '.parameters.imageVersion.allowedValues = $content[]' | Set-Content -Path "./FortiManager/${buildingBlock}/mainTemplate.json" | |
$content = Get-Content "./FortiManager/${buildingBlock}/mainTemplate.json" -Raw | |
if (-Not $content -match '(?<=\r\n)\z') { | |
"" | Out-File -Append "./FortiManager/${buildingBlock}/mainTemplate.json" | |
} | |
Get-Content -Raw -Path "./FortiManager/${buildingBlock}/createUiDefinition.json" | jq --slurpfile content "./fmgversionui.json" '(.parameters.basics[] | select( .name == \"imageVersion\") | .constraints.allowedValues) |= $content[]' | Set-Content -Path "./FortiManager/${buildingBlock}/createUiDefinition.json" | |
$content = Get-Content "./FortiManager/${buildingBlock}/createUiDefinition.json" -Raw | |
if (-Not $content -match '(?<=\r\n)\z') { | |
"" | Out-File -Append "./FortiManager/${buildingBlock}/createUiDefinition.json" | |
} | |
} | |
Remove-Item "./fmgversion.json" | |
Remove-Item "./fmgversionui.json" | |
azPSVersion: "latest" | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v4 | |
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: fmg-vm-update-version | |
delete-branch: true | |
title: '[FMG] Azure Marketplace FMG Version update' | |
body: | | |
Update report | |
- Updated FortiManager version in building blocks: "single-1nic", "ha-1nic" | |
- 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 |