-
Notifications
You must be signed in to change notification settings - Fork 57
83 lines (72 loc) · 3.39 KB
/
fmg-azure-marketplace-version-update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: '[FMG] Azure Marketplace version update'
on:
workflow_dispatch:
schedule:
- cron: '00 22 * * 0'
env:
PRODUCT: FortiManager
PRODUCTSHORT: FMG
PRODUCTOFFER: fortinet-fortimanager
PRODUCTSKU: fortinet-fortimanager
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")
$marketplaceVersions = @()
$marketplaceVersionsUI = @()
$marketplaceVersions = $(Get-AzVMImage -PublisherName "fortinet" -Location eastus -Offer "${env:PRODUCTOFFER}" -sku "${env:PRODUCTSKU}").Version
$marketplaceVersions += "latest"
[array]::Reverse($marketplaceVersions)
$marketplaceVersions | ConvertTo-Json | Out-File -Filepath "./fmgversion.json"
$marketplaceVersions | ForEach-Object { $marketplaceVersionsUI += [pscustomobject]@{label=$_;value=$_} }
$marketplaceVersionsUI | ConvertTo-Json | Out-File -Filepath "./fmgversionui.json"
foreach ($buildingBlock in $buildingBlocks) {
Get-Content -Raw -Path "./${env:PRODUCT}/${buildingBlock}/mainTemplate.json" | jq --slurpfile content "./fmgversion.json" '.parameters.imageVersion.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 "./fmgversionui.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 "./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 <[email protected]>
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", "ha"
- 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