Skip to content

Commit

Permalink
FPX: marketplace release test
Browse files Browse the repository at this point in the history
  • Loading branch information
jvhoof committed Aug 17, 2023
1 parent fa3d33e commit 93c49dc
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/fgt-azure-marketplace-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- "*"
- "!FPX-*"

workflow_dispatch:

Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/fpx-azure-marketplace-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: "[FGT] Azure Marketplace release"

on:
push:
tags:
- "FPX-*"

workflow_dispatch:

env:
PUBLISHER: Fortinet
PRODUCT: FortiProxy
PRODUCT: fortiproxy
PRODUCTSHORT: FPX
PRODUCTOFFER: fortinet-fortiproxy
PRODUCTSKU: fpx-vm-byol

jobs:
build:
name: Getting all data ready for publishing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Azure Login via Az module
uses: azure/[email protected]
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
enable-AzPSSession: true

- name: Package and convert templates
uses: azure/[email protected]
with:
inlineScript: |
$buildingBlocks = @("A-Single-VM", "Active-Active")
$marketplaceVersions = @()
$marketplaceVersionsUI = @()
$versions = Get-AzVMImage -PublisherName "${env:PUBLISHER}" -Location eastus -Offer "${env:PRODUCTOFFER}" -sku "${env:PRODUCTSKU}"
$marketplaceVersions += $($versions | Where-Object {$_.Version.StartsWith("6")} | Sort-Object -Unique -Property Version | Select-Object -Last 2).Version
$marketplaceVersions += $($versions | Where-Object {$_.Version.StartsWith("7")} | Sort-Object -Unique -Property Version | Select-Object -Last 2).Version
$marketplaceVersions += "latest"
$marketplaceVersions | ForEach-Object { $marketplaceVersionsUI += [pscustomobject]@{label=$_;value=$_} }
foreach ($buildingBlock in $buildingBlocks) {
$dest = "./releases/${buildingBlock}/"
[void](New-Item -Path "${dest}" -Type Directory)
$content = Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/azuredeploy.json" | ConvertFrom-Json
$content.parameters.fortiGateImageVersion.allowedValues = $marketplaceVersions
$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 "./${env:PRODUCT}/${buildingBlock}/createUiDefinition.json" | ConvertFrom-Json
$content.parameters.basics.Where({$_.Name.equals("fortiGateImageVersion")}).constraints.allowedValues = $marketplaceVersionsUI
$content | ConvertTo-Json -depth 100 | Out-File "${dest}/createUiDefinition.json"
"" | Out-File -Append "${dest}/createUiDefinition.json"
}
Compress-Archive -Path "./releases/*" -DestinationPath "./releases/${env:PRODUCT}.ToLower()-azure-templates.zip"
azPSVersion: "latest"

- name: upload-templates-zip
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
file: ./releases/${env:PRODUCT}.ToLower()-azure-templates.zip
asset_name: ${env:PRODUCT}.ToLower()-azure-templates.zip
tag: ${{github.ref}}
overwrite: true
body: "${env:PRODUCT} Azure Marketplace Release"

0 comments on commit 93c49dc

Please sign in to comment.