diff --git a/tools/BranchSync/config.json b/.azure-pipelines/SyncFromMainBranchConfig.json similarity index 70% rename from tools/BranchSync/config.json rename to .azure-pipelines/SyncFromMainBranchConfig.json index 7d47ea437c5d..018154bbd8e5 100644 --- a/tools/BranchSync/config.json +++ b/.azure-pipelines/SyncFromMainBranchConfig.json @@ -6,6 +6,6 @@ "build.proj" ], "UnSyncPath": [ - "tools/BranchSync" + ".azure-pipelines/SyncFromMainBranchConfig.json" ] } \ No newline at end of file diff --git a/.azure-pipelines/sync-tools-folder.yml b/.azure-pipelines/sync-tools-folder.yml index 1cf468f4882d..307a3180f8cb 100644 --- a/.azure-pipelines/sync-tools-folder.yml +++ b/.azure-pipelines/sync-tools-folder.yml @@ -35,5 +35,5 @@ jobs: inputs: targetType: inline script: >- - ./tools/BranchSync/BranchSync.ps1 -BranchName $(BranchName) -GithubToken $env:GITHUB_TOKEN + ./tools/SyncFromMainBranch.ps1 -BranchName $(BranchName) -GithubToken $env:GITHUB_TOKEN pwsh: true diff --git a/tools/BranchSync/BranchSync.ps1 b/tools/SyncFromMainBranch.ps1 similarity index 84% rename from tools/BranchSync/BranchSync.ps1 rename to tools/SyncFromMainBranch.ps1 index 41cf244ea666..362fa06ec7a2 100644 --- a/tools/BranchSync/BranchSync.ps1 +++ b/tools/SyncFromMainBranch.ps1 @@ -6,13 +6,13 @@ param( [string]$GithubToken ) -$Config = Get-Content (Join-Path $PSScriptRoot "config.json") | ConvertFrom-Json +$Config = Get-Content (Join-Path $PSScriptRoot "../.azure-pipelines/SyncFromMainBranchConfig.json") | ConvertFrom-Json $TmpFolder = New-Item -ItemType Directory -Path tmp foreach ($SyncPath in $Config.SyncPath) { Write-Host "Back up $SyncPath from main branch." - Copy-Item -Path $SyncPath -Destination "$TmpFolder/$SyncPath" -Recurse + Copy-Item -Path $SyncPath -Destination "$TmpFolder/$SyncPath" -Recurse -Force } git config --global user.email "azurepowershell@ms.com" @@ -30,10 +30,10 @@ foreach ($UnSyncPath in $Config.UnSyncPath) foreach ($SyncPath in $Config.SyncPath) { Remove-Item -Path $SyncPath -Recurse - Copy-Item -Path "$TmpFolder/$SyncPath" -Destination $SyncPath -Recurse + Copy-Item -Path "$TmpFolder/$SyncPath" -Destination $SyncPath -Recurse -Force git add $SyncPath } git commit -m "Sync tools folder from main branch to $BranchName branch" git remote set-url origin "https://$GithubToken@github.com/Azure/azure-powershell.git" -git push origin "syncToolsFolder-$BranchName" --force \ No newline at end of file +git push origin "syncToolsFolder-$BranchName" --force