Skip to content

Update pipeline and workflow references #3469

Closed

Description

Update both GitHub and Azure DevOps pipelines to use new folder names.

You can use the following script to automate this step:

$mappings = ConvertFrom-Json (Get-Content -Path 'C:\dev\ip\Azure-ResourceModules\ResourceModules\rtMapping.jsonc' -Raw) -AsHashtable


# GitHub
$pipelinePaths = (Get-ChildItem -Path 'C:\dev\ip\Azure-ResourceModules\ResourceModules\.github\workflows').FullName | Where-Object {
    $_ -match 'ms\..+'
}

# DevOps
$pipelinePaths += (Get-ChildItem -Path 'C:\dev\ip\Azure-ResourceModules\ResourceModules\.azuredevops\modulePipelines').FullName

foreach ($path in $pipelinePaths) {
    $content = Get-Content -Path $path

    for ($index = 0; $index -lt $content.Count; $index++) {
        $line = $content[$index]

        if ($line -match '(.+modules\/)([a-zA-Z-]+)\/([a-zA-Z-]+)(.*)') {
            $prefix = $Matches[1]
            $providerNamespace = $Matches[2]
            $resourceType = $Matches[3]
            $suffix = $Matches[4]

            if ($mappings.Keys -contains $resourceType) {
                $newResourceType = $mappings[$resourceType]
            } else {
                Write-Verbose "No mapping found for [$resourceType]"
                continue
            }

            $content[$index] = '{0}{1}/{2}{3}' -f $prefix, $providerNamespace, $newResourceType, $suffix
        }
    }

    Set-Content -Path $path -Value $content -Force
}

Metadata

Metadata

Labels

[cat] pipelines

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions