Skip to content

Commit fdae6f3

Browse files
migration table edit
1 parent f062354 commit fdae6f3

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tools/GitHub/Invoke-ExecCommunityRepo.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,18 @@ function Invoke-ExecCommunityRepo {
162162
$Branch = $Request.Body.Branch
163163
try {
164164
$Template = Get-GitHubFileContents -FullName $FullName -Path $Path -Branch $Branch
165+
165166
$Content = $Template.content | ConvertFrom-Json
166-
Import-CommunityTemplate -Template $Content -SHA $Template.sha
167+
if ($Content.'@odata.type' -like '*conditionalAccessPolicy*') {
168+
$Files = (Get-GitHubFileTree -FullName $FullName -Branch $Branch).tree | Where-Object { $_.path -match '.json$' -and $_.path -notmatch 'NativeImport' } | Select-Object *, @{n = 'html_url'; e = { "https://github.com/$($SplatParams.FullName)/tree/$($SplatParams.Branch)/$($_.path)" } }, @{n = 'name'; e = { ($_.path -split '/')[ -1 ] -replace '\.json$', '' } }
169+
170+
$MigrationTable = $Files | Where-Object { $_.name -eq 'MigrationTable' } | Select-Object -Last 1
171+
if ($MigrationTable) {
172+
Write-Host 'Found a migration table, getting contents'
173+
$MigrationTable = (Get-GitHubFileContents -FullName $FullName -Branch $Branch -Path $MigrationTable.path).content | ConvertFrom-Json
174+
}
175+
}
176+
Import-CommunityTemplate -Template $Content -SHA $Template.sha -MigrationTable $MigrationTable
167177
$Results = @{
168178
resultText = 'Template imported'
169179
state = 'success'

0 commit comments

Comments
 (0)