Skip to content

[FPX] Azure Marketplace version update #64

[FPX] Azure Marketplace version update

[FPX] Azure Marketplace version update #64

name: '[FPX] Azure Marketplace version update'
on:
workflow_dispatch:
schedule:
- cron: '00 22 * * 0'
env:
PRODUCT: FortiProxy
PRODUCTSHORT: FPX
PRODUCTOFFER: fortinet-fortiproxy
PRODUCTSKU: fpx-vm-byol
jobs:
ARM-FPX-Version-Update:
name: Update FPX 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 FPX published version, update templates when new version found
uses: azure/powershell@v2
with:
inlineScript: |
$buildingBlocks = @("A-Single-VM", "Active-Active")
$marketplaceVersions = @()
$marketplaceVersionsUI = @()
$versions = Get-AzVMImage -PublisherName "fortinet" -Location eastus -Offer "${env:PRODUCTOFFER}" -sku "${env:PRODUCTSKU}"
$marketplaceVersions += $($versions).Version
$marketplaceVersions += "latest"
$marketplaceVersions | ConvertTo-Json | Out-File -Filepath "./version.json"
$marketplaceVersions | ForEach-Object { $marketplaceVersionsUI += [pscustomobject]@{label=$_;value=$_} }
$marketplaceVersionsUI | ConvertTo-Json | Out-File -Filepath "./versionui.json"
foreach ($buildingBlock in $buildingBlocks) {
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" | jq --slurpfile content "./version.json" '.parameters.fortiProxyImageVersion.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}/createUiDefinition.json" | jq --slurpfile content "./versionui.json" '(.parameters.basics[] | select( .name == "imageVersion") | .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 "./version.json"
Remove-Item "./versionui.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: fpx-vm-update-version
delete-branch: true
title: '[FPX] Azure Marketplace FPX Version update'
body: |
Update report
- Updated ${{ env.PRODUCT }} version in building blocks: "A-Single-VM", "Active-Active"
- 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