Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 29 additions & 23 deletions utilities/tools/ConvertTo-ARMTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ if ($ConvertChildren) {
#region Remove existing deploy.json files
Write-Verbose 'Remove existing deploy.json files'

$JsonFilesToRemove = Get-ChildItem -Path $armFolderPath -Filter 'deploy.json' -Recurse -Force -File
Write-Verbose "Remove existing deploy.json files - Remove [$($JsonFilesToRemove.count)] file(s)"
if ($PSCmdlet.ShouldProcess("[$($JsonFilesToRemove.count)] deploy.json files(s) in path [$armFolderPath]", 'Remove-Item')) {
$JsonFilesToRemove | Remove-Item -Force
if (Test-Path -Path (Join-Path -Path $armFolderPath -ChildPath 'deploy.bicep')) {
$JsonFilesToRemove = Get-ChildItem -Path $armFolderPath -Filter 'deploy.json' -Recurse -Force -File
Write-Verbose "Remove existing deploy.json files - Remove [$($JsonFilesToRemove.count)] file(s)"
if ($PSCmdlet.ShouldProcess("[$($JsonFilesToRemove.count)] deploy.json files(s) in path [$armFolderPath]", 'Remove-Item')) {
$JsonFilesToRemove | Remove-Item -Force
}
Write-Verbose 'Remove existing deploy.json files - Done'
}

Write-Verbose 'Remove existing deploy.json files - Done'
#endregion

#region Convert bicep files to json
Expand Down Expand Up @@ -173,29 +175,33 @@ if (-not $SkipPipelineUpdate) {

# GitHub workflow files
$ghWorkflowFolderPath = Join-Path -Path $rootPath -ChildPath '.github\workflows'
$ghWorkflowFilesToUpdate = Get-ChildItem -Path $ghWorkflowFolderPath -Filter 'ms.*.yml' -File -Force
Write-Verbose ('Update workflow files - Processing [{0}] file(s)' -f $ghWorkflowFilesToUpdate.count)
if ($PSCmdlet.ShouldProcess(('[{0}] ms.*.yml file(s) in path [{1}]' -f $ghWorkflowFilesToUpdate.Count, $ghWorkflowFolderPath), 'Set-Content')) {
# parallelism is not supported on GitHub runners
#$ghWorkflowFilesToUpdate | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel {
$ghWorkflowFilesToUpdate | ForEach-Object {
$content = $_ | Get-Content
$content = $content -replace 'templateFilePath:(.*).bicep', 'templateFilePath:$1.json'
$_ | Set-Content -Value $content
if (Test-Path -Path $ghWorkflowFolderPath) {
$ghWorkflowFilesToUpdate = Get-ChildItem -Path $ghWorkflowFolderPath -Filter 'ms.*.yml' -File -Force
Write-Verbose ('Update workflow files - Processing [{0}] file(s)' -f $ghWorkflowFilesToUpdate.count)
if ($PSCmdlet.ShouldProcess(('[{0}] ms.*.yml file(s) in path [{1}]' -f $ghWorkflowFilesToUpdate.Count, $ghWorkflowFolderPath), 'Set-Content')) {
# parallelism is not supported on GitHub runners
#$ghWorkflowFilesToUpdate | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel {
$ghWorkflowFilesToUpdate | ForEach-Object {
$content = $_ | Get-Content
$content = $content -replace 'templateFilePath:(.*).bicep', 'templateFilePath:$1.json'
$_ | Set-Content -Value $content
}
}
}

# Azure DevOps Pipelines
$adoPipelineFolderPath = Join-Path -Path $rootPath -ChildPath '.azuredevops\modulePipelines'
$adoPipelineFilesToUpdate = Get-ChildItem -Path $adoPipelineFolderPath -Filter 'ms.*.yml' -File -Force
Write-Verbose ('Update Azure DevOps pipeline files - Processing [{0}] file(s)' -f $adoPipelineFilesToUpdate.count)
if ($PSCmdlet.ShouldProcess(('[{0}] ms.*.yml file(s) in path [{1}]' -f $adoPipelineFilesToUpdate.Count, $adoPipelineFolderPath), 'Set-Content')) {
# parallelism is not supported on GitHub runners
#$adoPipelineFilesToUpdate | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel {
$adoPipelineFilesToUpdate | ForEach-Object {
$content = $_ | Get-Content
$content = $content -replace 'templateFilePath:(.*).bicep', 'templateFilePath:$1.json'
$_ | Set-Content -Value $content
if (Test-Path -Path $adoPipelineFolderPath) {
$adoPipelineFilesToUpdate = Get-ChildItem -Path $adoPipelineFolderPath -Filter 'ms.*.yml' -File -Force
Write-Verbose ('Update Azure DevOps pipeline files - Processing [{0}] file(s)' -f $adoPipelineFilesToUpdate.count)
if ($PSCmdlet.ShouldProcess(('[{0}] ms.*.yml file(s) in path [{1}]' -f $adoPipelineFilesToUpdate.Count, $adoPipelineFolderPath), 'Set-Content')) {
# parallelism is not supported on GitHub runners
#$adoPipelineFilesToUpdate | ForEach-Object -ThrottleLimit $env:NUMBER_OF_PROCESSORS -Parallel {
$adoPipelineFilesToUpdate | ForEach-Object {
$content = $_ | Get-Content
$content = $content -replace 'templateFilePath:(.*).bicep', 'templateFilePath:$1.json'
$_ | Set-Content -Value $content
}
}
}

Expand Down