Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .azure-pipelines/SyncDocsConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"SyncPath": [
"documentation/breaking-changes/upcoming-breaking-changes.md"
],
"UnSyncPath": [
]
}
56 changes: 56 additions & 0 deletions .azure-pipelines/sync-MSdoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
resources:
repositories:
- repository: self
type: git
ref: main

trigger:
branches:
include:
- main
paths:
include:
- documentation\breaking-changes\upcoming-breaking-changes.md

variables:
TargetedRepo: azure-docs-powershell
TargetedBranchName: sync-upcoming-breaking-changes
GithubToken: $(GITHUB_TOKEN)

jobs:
- job: Sync
displayName: Sync task
condition: succeeded()
strategy:
matrix:
Generation:
BranchName: ${{ variables.TargetedBranchName }}

steps:
- task: PowerShell@2
displayName: Sync branch
inputs:
targetType: inline
script: >-
./tools/SyncDocsToMicrosoftDocsOrg.ps1 -BranchName $(BranchName) -GithubToken $(GithubToken)
pwsh: true

- pwsh: |
$Title = "Sync upcoming breaking changes docs from Azure/azure-powershell repo"
$HeadBranch = "$(BranchName)"
$BaseBranch = "main"
$Description = "Sync latest upcoming breaking changes doc from Azure/azure-powershell repo."
$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $(GithubToken)"}
$PrBody = @"
<!-- DO NOT DELETE THIS TEMPLATE -->

## Description
$Description

<!-- Please add a brief description of the changes made in this PR. If you have an ongoing or finished cmdlet design, please paste the link below. -->
"@
$RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch }
Invoke-WebRequest -Uri https://api.github.com/repos/MicrosoftDocs/azure-docs-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json)

continueOnError: true
displayName: Create PR to main branch
64 changes: 64 additions & 0 deletions tools/SyncDocsToMicrosoftDocsOrg.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Sync doc from Azure/azure-powershell to MicrosoftDocs/azure-docs-powershell
[CmdletBinding()]
param(
[Parameter()]
[string]$RepoName = "azure-docs-powershell",
[Parameter()]
[string]$OrgName = "MicrosoftDocs",
[Parameter()]
[string]$BranchName,
[Parameter()]
[string]$WorkSpace,
[Parameter()]
[string]$GithubToken
)

# The absolute location of repos
$WorkSpace = (Resolve-Path (Join-Path $PSScriptRoot "../../")).Path
$RepoCloneLink = "https://github.com/$OrgName/$RepoName.git"
$Config = Get-Content (Join-Path $PSScriptRoot "../.azure-pipelines/SyncDocsConfig.json") | ConvertFrom-Json
$TmpFolder = Resolve-Path (New-Item -ItemType Directory -Path tmp)
# Get az version to match target folder
$AzVersion = (Import-PowerShellDataFile -Path "$PSScriptRoot\Az\Az.psd1").ModuleVersion

foreach ($SyncPath in $Config.SyncPath)
{
Write-Host "Back up $SyncPath from main branch."
Copy-Item -Path $SyncPath -Destination $TmpFolder -Recurse -Force
}

$SyncFile = Split-Path $SyncPath -Leaf

git config user.email "[email protected]"
git config user.name "azure-powershell-bot"

cd $WorkSpace
git clone $RepoCloneLink
cd $RepoName
git checkout -b $BranchName


foreach ($SyncPath in $Config.SyncPath)
{
$Date = Get-Date -Format MM/dd/yyyy
$Header = @"
---
description: Learn about upcoming breaking changes to the Azure Az PowerShell module
ms.custom: devx-track-azurepowershell
ms.date: $Date
ms.devlang: powershell
ms.service: azure-powershell
ms.topic: conceptual
title: Upcoming breaking changes in Azure PowerShell
---

"@

$Header + (Get-Content $TmpFolder\$SyncFile -Raw) | Set-Content $TmpFolder\$SyncFile
Copy-Item $TmpFolder\$SyncFile (Join-Path $WorkSpace $RepoName/docs-conceptual/azps-$AzVersion) -Force
git add (Join-Path $WorkSpace $RepoName/docs-conceptual/azps-$AzVersion)
}

git commit -m "Sync upcoming breaking changes doc from azure-powershell repo."
git remote set-url origin "https://[email protected]/$OrgName/$RepoName.git"
git push origin "$BranchName" --force