Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pipeline and workflow references #3469

Closed
Tracked by #3452
AlexanderSehr opened this issue Jul 30, 2023 · 0 comments · Fixed by #3455
Closed
Tracked by #3452

Update pipeline and workflow references #3469

AlexanderSehr opened this issue Jul 30, 2023 · 0 comments · Fixed by #3455
Assignees
Labels
[cat] pipelines category: pipelines

Comments

@AlexanderSehr
Copy link
Contributor

AlexanderSehr commented Jul 30, 2023

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[cat] pipelines category: pipelines
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants