@@ -9,6 +9,7 @@ function New-CIPPTemplateRun {
99 $data = $_.JSON | ConvertFrom-Json - ErrorAction SilentlyContinue - Depth 100
1010 $data | Add-Member - NotePropertyName ' GUID' - NotePropertyValue $_.RowKey - Force
1111 $data | Add-Member - NotePropertyName ' PartitionKey' - NotePropertyValue $_.PartitionKey - Force
12+ $data | Add-Member - NotePropertyName ' SHA' - NotePropertyValue $_.SHA - Force
1213 $data
1314 } | Sort-Object - Property displayName
1415
@@ -20,21 +21,25 @@ function New-CIPPTemplateRun {
2021 }
2122 if ($TemplateSettings.templateRepo ) {
2223 Write-Host ' Grabbing data from required community repo'
23- $Files = (Get-GitHubFileTree - FullName $TemplateSettings.templateRepo.value - Branch $TemplateSettings.templateRepo.branch ).tree | Where-Object { $_.path -match ' .json$' } | Select-Object * , @ {n = ' html_url' ; e = { " https://github.com/$ ( $SplatParams.FullName ) /tree/$ ( $SplatParams.Branch ) /$ ( $_.path ) " } }, @ {n = ' name' ; e = { ($_.path -split ' /' )[ -1 ] -replace ' \.json$' , ' ' } }
24+ $Files = (Get-GitHubFileTree - FullName $TemplateSettings.templateRepo.value - Branch $TemplateSettings.templateRepoBranch.value ).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$' , ' ' } }
2425 foreach ($File in $Files ) {
2526 $ExistingTemplate = $ExistingTemplates | Where-Object { $_.displayName -eq $File.name } | Select-Object - First 1
27+ $Template = (Get-GitHubFileContents - FullName $TemplateSettings.templateRepo.value - Branch $TemplateSettings.templateRepoBranch.value - Path $File.path ).content | ConvertFrom-Json
2628 if ($ExistingTemplate ) {
2729 $UpdateNeeded = $false
2830 if ($ExistingTemplate.sha -ne $File.sha -or ! $ExistingTemplate.sha ) {
2931 $UpdateNeeded = $true
3032 }
3133 if ($UpdateNeeded ) {
32- $Template = Get-GitHubFileContents - FullName $TemplateSettings .templateRepo.value - Branch $TemplateSettings .templateRepo.branch - Path $File .path | ConvertFrom-Json
34+ Write-Host " Template $ ( $File .name ) needs to be updated as the SHA is different "
3335 Import-CommunityTemplate - Template $Template - SHA $File.sha
3436 }
37+ } else {
38+ Write-Host " Template $ ( $File.name ) needs to be created"
39+ Import-CommunityTemplate - Template $Template - SHA $File.sha
40+
3541 }
3642 }
37-
3843 } else {
3944 foreach ($Task in $Tasks ) {
4045 Write-Host " Working on task $Task "
0 commit comments