|
| 1 | +# Sync doc from Azure/azure-powershell to MicrosoftDocs/azure-docs-powershell |
| 2 | +[CmdletBinding()] |
| 3 | +param( |
| 4 | + [Parameter()] |
| 5 | + [string]$RepoName = "azure-docs-powershell", |
| 6 | + [Parameter()] |
| 7 | + [string]$OrgName = "MicrosoftDocs", |
| 8 | + [Parameter()] |
| 9 | + [string]$BranchName, |
| 10 | + [Parameter()] |
| 11 | + [string]$WorkSpace, |
| 12 | + [Parameter()] |
| 13 | + [string]$GithubToken |
| 14 | +) |
| 15 | + |
| 16 | +# The absolute location of repos |
| 17 | +$WorkSpace = (Resolve-Path (Join-Path $PSScriptRoot "../../")).Path |
| 18 | +$RepoCloneLink = "https://github.com/$OrgName/$RepoName.git" |
| 19 | +$Config = Get-Content (Join-Path $PSScriptRoot "../.azure-pipelines/SyncDocsConfig.json") | ConvertFrom-Json |
| 20 | +$TmpFolder = Resolve-Path (New-Item -ItemType Directory -Path tmp) |
| 21 | +# Get az version to match target folder |
| 22 | +$AzVersion = (Import-PowerShellDataFile -Path "$PSScriptRoot\Az\Az.psd1").ModuleVersion |
| 23 | + |
| 24 | +foreach ($SyncPath in $Config.SyncPath) |
| 25 | +{ |
| 26 | + Write-Host "Back up $SyncPath from main branch." |
| 27 | + Copy-Item -Path $SyncPath -Destination $TmpFolder -Recurse -Force |
| 28 | +} |
| 29 | + |
| 30 | +$SyncFile = Split-Path $SyncPath -Leaf |
| 31 | + |
| 32 | +git config user.email "[email protected]" |
| 33 | +git config user.name "azure-powershell-bot" |
| 34 | + |
| 35 | +cd $WorkSpace |
| 36 | +git clone $RepoCloneLink |
| 37 | +cd $RepoName |
| 38 | +git checkout -b $BranchName |
| 39 | + |
| 40 | + |
| 41 | +foreach ($SyncPath in $Config.SyncPath) |
| 42 | +{ |
| 43 | + $Date = Get-Date -Format MM/dd/yyyy |
| 44 | + $Header = @" |
| 45 | +--- |
| 46 | +description: Learn about upcoming breaking changes to the Azure Az PowerShell module |
| 47 | +ms.custom: devx-track-azurepowershell |
| 48 | +ms.date: $Date |
| 49 | +ms.devlang: powershell |
| 50 | +ms.service: azure-powershell |
| 51 | +ms.topic: conceptual |
| 52 | +title: Upcoming breaking changes in Azure PowerShell |
| 53 | +--- |
| 54 | +
|
| 55 | +"@ |
| 56 | + |
| 57 | + $Header + (Get-Content $TmpFolder\$SyncFile -Raw) | Set-Content $TmpFolder\$SyncFile |
| 58 | + Copy-Item $TmpFolder\$SyncFile (Join-Path $WorkSpace $RepoName/docs-conceptual/azps-$AzVersion) -Force |
| 59 | + git add (Join-Path $WorkSpace $RepoName/docs-conceptual/azps-$AzVersion) |
| 60 | +} |
| 61 | + |
| 62 | +git commit -m "Sync upcoming breaking changes doc from azure-powershell repo." |
| 63 | +git remote set-url origin "https://$GithubToken@github.com/$OrgName/$RepoName.git" |
| 64 | +git push origin "$BranchName" --force |
0 commit comments