From 2e9c6d24c49ad59aede40719375c44dc1cbacbc6 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Mon, 30 Jan 2023 10:26:49 +0800 Subject: [PATCH 01/84] add pipeline yml for syncing fabricbot.json aliases --- .azure-pipelines/sync-aliases.yml | 100 ++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .azure-pipelines/sync-aliases.yml diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml new file mode 100644 index 000000000000..60ed3b9af0a8 --- /dev/null +++ b/.azure-pipelines/sync-aliases.yml @@ -0,0 +1,100 @@ +resources: + repositories: + - repository: self + type: git + ref: main + +trigger: none + +variables: + GithubToken: $(GITHUB_TOKEN) + +jobs: +- job: UpdateJson + displayName: Update Json + steps: + - checkout: self + persistCredentials: true + - task: PowerShell@2 + displayName: Update json file + inputs: + targetType: inline + script: | + $username="v-hongtzhang" + $password='$(AZURE-PASS)' + $pair="{0}:{1}" -f ($username,$password) + $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) + $token = [System.Convert]::ToBase64String($bytes) + $headers = @{ + Authorization = "Basic {0}" -f ($token) + } + $response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers + + $rows = ($response.content -split "\n") | Select-Object -Skip 6 + $aliases = [System.Collections.SortedList]::new() + + foreach ($item in $rows) + { + $list = $item -split "\|" + if ($list.Count -eq 1) { continue } + if ($list[1].Trim().Length -gt 0) + { + if ($list.Count -gt 3) + { + $aliases.Add($list[1].Trim(), $list[3].Trim()) + } + else + { + $aliases.Add($list[1].Trim(), "") + } + } + } + $whole_json = Get-Content -Raw -Path .github/fabricbot.json | ConvertFrom-Json + + $whole_json.tasks | ForEach-Object { + if($_.taskType -eq 'scheduledAndTrigger') { + $labelsAndMentionsArrayList = New-Object System.Collections.ArrayList + foreach ($entry in $aliases.GetEnumerator()) { + if ($entry.Value -eq "") { + continue + } + $labels = @("Service Attention", $entry.Key) + $mentionees = @($entry.Value -split "," | ForEach-Object { $_.Trim() }) + $item = [PSCustomObject]@{ + labels = $labels + mentionees = $mentionees + } + [void]$labelsAndMentionsArrayList.Add($item) + } + $_.config.labelsAndMentions = $labelsAndMentionsArrayList.ToArray() + + } + } + ($whole_json | ConvertTo-Json -Depth 32) | Out-File -FilePath .github/fabricbot.json + pwsh: true + + - task: PowerShell@2 + displayName: Commit and Push + inputs: + targetType: inline + script: | + git pull origin main + git config --global user.email "nicolasshuai@gmail.com" + git config --global user.name "xtr0d666" + git config --global credential.helper store + git checkout -b "Will_change_fabricbot" + + git add . + git commit -m "pipeline to change fabricbot22.json" + + git remote set-url origin "https://$(GITHUB_TOKEN)@github.com/xtR0d666/azure-powershell.git" + git push origin Will_change_fabricbot --force + + - pwsh: | + $Title = "Change Fabricbot.json According To Wiki Page" + $HeadBranch = "Will_change_fabricbot" + $BaseBranch = "main" + $Description = "Use powershell to sort taskType: scheduledAndTrigger part of fabricbot.json according to table of Service-Team-Label-and-Contact-List in wiki page" + ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(GITHUB_TOKEN) -Description $Description + displayName: Create PR to main branch + \ No newline at end of file From f77bd2167dd6192a5cef8118047d482b9fb04c12 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Mon, 30 Jan 2023 13:09:59 +0800 Subject: [PATCH 02/84] change git user name and email in script --- .azure-pipelines/sync-aliases.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 60ed3b9af0a8..9ad88c683843 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -79,15 +79,15 @@ jobs: targetType: inline script: | git pull origin main - git config --global user.email "nicolasshuai@gmail.com" - git config --global user.name "xtr0d666" + git config --global user.email "azurepowershell@ms.com" + git config --global user.name "azurepowershell" git config --global credential.helper store git checkout -b "Will_change_fabricbot" git add . git commit -m "pipeline to change fabricbot22.json" - git remote set-url origin "https://$(GITHUB_TOKEN)@github.com/xtR0d666/azure-powershell.git" + git remote set-url origin "https://$(GITHUB_TOKEN)@github.com/Azure/azure-powershell.git" git push origin Will_change_fabricbot --force - pwsh: | From 38b1f70d8b04f674176c58448ae6f0758ea0048c Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 11:59:10 +0800 Subject: [PATCH 03/84] change inline script to GetWiki2Json.ps1 file --- .azure-pipelines/sync-aliases.yml | 70 +++------------------------ tools/Github/GetWiki2Json.ps1 | 80 +++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 63 deletions(-) create mode 100644 tools/Github/GetWiki2Json.ps1 diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 9ad88c683843..f154239f9b94 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,3 +1,4 @@ +# Variable 'AzureToken' and 'BotAccessToken' was defined in the Variables tab resources: repositories: - repository: self @@ -6,72 +7,15 @@ resources: trigger: none -variables: - GithubToken: $(GITHUB_TOKEN) - jobs: - job: UpdateJson displayName: Update Json steps: - checkout: self persistCredentials: true - - task: PowerShell@2 + - pwsh: | + ./tools/Github/GetWiki2Json.ps1 -AzureToken $(AzureToken) displayName: Update json file - inputs: - targetType: inline - script: | - $username="v-hongtzhang" - $password='$(AZURE-PASS)' - $pair="{0}:{1}" -f ($username,$password) - $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) - $token = [System.Convert]::ToBase64String($bytes) - $headers = @{ - Authorization = "Basic {0}" -f ($token) - } - $response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers - - $rows = ($response.content -split "\n") | Select-Object -Skip 6 - $aliases = [System.Collections.SortedList]::new() - - foreach ($item in $rows) - { - $list = $item -split "\|" - if ($list.Count -eq 1) { continue } - if ($list[1].Trim().Length -gt 0) - { - if ($list.Count -gt 3) - { - $aliases.Add($list[1].Trim(), $list[3].Trim()) - } - else - { - $aliases.Add($list[1].Trim(), "") - } - } - } - $whole_json = Get-Content -Raw -Path .github/fabricbot.json | ConvertFrom-Json - - $whole_json.tasks | ForEach-Object { - if($_.taskType -eq 'scheduledAndTrigger') { - $labelsAndMentionsArrayList = New-Object System.Collections.ArrayList - foreach ($entry in $aliases.GetEnumerator()) { - if ($entry.Value -eq "") { - continue - } - $labels = @("Service Attention", $entry.Key) - $mentionees = @($entry.Value -split "," | ForEach-Object { $_.Trim() }) - $item = [PSCustomObject]@{ - labels = $labels - mentionees = $mentionees - } - [void]$labelsAndMentionsArrayList.Add($item) - } - $_.config.labelsAndMentions = $labelsAndMentionsArrayList.ToArray() - - } - } - ($whole_json | ConvertTo-Json -Depth 32) | Out-File -FilePath .github/fabricbot.json - pwsh: true - task: PowerShell@2 displayName: Commit and Push @@ -79,15 +23,15 @@ jobs: targetType: inline script: | git pull origin main - git config --global user.email "azurepowershell@ms.com" - git config --global user.name "azurepowershell" + git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" + git config --global user.name "azure-powershell-bot" git config --global credential.helper store git checkout -b "Will_change_fabricbot" git add . git commit -m "pipeline to change fabricbot22.json" - git remote set-url origin "https://$(GITHUB_TOKEN)@github.com/Azure/azure-powershell.git" + git remote set-url origin https://azure-powershell-bot:$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin Will_change_fabricbot --force - pwsh: | @@ -95,6 +39,6 @@ jobs: $HeadBranch = "Will_change_fabricbot" $BaseBranch = "main" $Description = "Use powershell to sort taskType: scheduledAndTrigger part of fabricbot.json according to table of Service-Team-Label-and-Contact-List in wiki page" - ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(GITHUB_TOKEN) -Description $Description + ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description displayName: Create PR to main branch \ No newline at end of file diff --git a/tools/Github/GetWiki2Json.ps1 b/tools/Github/GetWiki2Json.ps1 new file mode 100644 index 000000000000..b9935d072941 --- /dev/null +++ b/tools/Github/GetWiki2Json.ps1 @@ -0,0 +1,80 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- + +<# +.SYNOPSIS + Sync ADO wiki aliases content to fabricbot.json. + +#> +param( + [Parameter(Mandatory = $true)] + [string]$AzureToken +) + +# get wiki content +$username="" +$password='$(AzureToken)' +$pair="{0}:{1}" -f ($username,$password) +$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) +$token = [System.Convert]::ToBase64String($bytes) +$headers = @{ + Authorization = "Basic {0}" -f ($token) +} + +$response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers +Write-Host $response + +$rows = ($response.content -split "\n") | Select-Object -Skip 6 +$aliases = [System.Collections.SortedList]::new() + +foreach ($item in $rows) +{ + $list = $item -split "\|" + if ($list.Count -eq 1) { continue } + if ($list[1].Trim().Length -gt 0) + { + if ($list.Count -gt 3) + { + $aliases.Add($list[1].Trim(), $list[3].Trim()) + } + else + { + $aliases.Add($list[1].Trim(), "") + } + } +} + +# change json file +$whole_json = Get-Content -Raw -Path .github/fabricbot.json | ConvertFrom-Json + +$whole_json.tasks | ForEach-Object { + if($_.taskType -eq 'scheduledAndTrigger') { + $labelsAndMentionsArrayList = New-Object System.Collections.ArrayList + foreach ($entry in $aliases.GetEnumerator()) { + if ($entry.Value -eq "") { + continue + } + $labels = @("Service Attention!!!!!!", $entry.Key) + $mentionees = @($entry.Value -split "," | ForEach-Object { $_.Trim() }) + $item = [PSCustomObject]@{ + labels = $labels + mentionees = $mentionees + } + [void]$labelsAndMentionsArrayList.Add($item) + } + $_.config.labelsAndMentions = $labelsAndMentionsArrayList.ToArray() + } +} + +($whole_json | ConvertTo-Json -Depth 32) | Out-File -FilePath ../.github/fabricbot.json From 2e5c08a0e15e992bbbe2741a83de3e67538d1457 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 14:22:26 +0800 Subject: [PATCH 04/84] remove unnecessary code --- .azure-pipelines/sync-aliases.yml | 10 ++++------ tools/Github/{GetWiki2Json.ps1 => ParseWiki2Json.ps1} | 0 2 files changed, 4 insertions(+), 6 deletions(-) rename tools/Github/{GetWiki2Json.ps1 => ParseWiki2Json.ps1} (100%) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index f154239f9b94..d2540711bde3 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -12,24 +12,22 @@ jobs: displayName: Update Json steps: - checkout: self - persistCredentials: true - pwsh: | - ./tools/Github/GetWiki2Json.ps1 -AzureToken $(AzureToken) - displayName: Update json file + ./tools/Github/ParseWiki2Json.ps1 -AzureToken $(AzureToken) + displayName: Update fabricbot.json file locally - task: PowerShell@2 - displayName: Commit and Push + displayName: Commit and push inputs: targetType: inline script: | git pull origin main git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" - git config --global credential.helper store git checkout -b "Will_change_fabricbot" git add . - git commit -m "pipeline to change fabricbot22.json" + git commit -m "Use pipeline to sync fabricbot22.json" git remote set-url origin https://azure-powershell-bot:$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin Will_change_fabricbot --force diff --git a/tools/Github/GetWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 similarity index 100% rename from tools/Github/GetWiki2Json.ps1 rename to tools/Github/ParseWiki2Json.ps1 From 80aa187afd8374c636fd1a6ed708cdacc38b6d2d Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 14:31:38 +0800 Subject: [PATCH 05/84] change wrong dir --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index b9935d072941..9bac37ff8793 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -77,4 +77,4 @@ $whole_json.tasks | ForEach-Object { } } -($whole_json | ConvertTo-Json -Depth 32) | Out-File -FilePath ../.github/fabricbot.json +($whole_json | ConvertTo-Json -Depth 32) | Out-File -FilePath .github/fabricbot.json From 283117243052df0d8603f32bf7f2ae9960c5195c Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 15:13:53 +0800 Subject: [PATCH 06/84] change to my personal repo for test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index d2540711bde3..de8d29837c7c 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -29,7 +29,7 @@ jobs: git add . git commit -m "Use pipeline to sync fabricbot22.json" - git remote set-url origin https://azure-powershell-bot:$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; git push origin Will_change_fabricbot --force - pwsh: | From 74313ffbd17d50ef9c7ef77239ee66a57d05e2b9 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 15:26:38 +0800 Subject: [PATCH 07/84] change the usage of token --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index 9bac37ff8793..eec54c653f50 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -24,7 +24,7 @@ param( # get wiki content $username="" -$password='$(AzureToken)' +$password='$AzureToken' $pair="{0}:{1}" -f ($username,$password) $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $token = [System.Convert]::ToBase64String($bytes) From d25175c7b646ac0f265a06d35fc956c85db33ac6 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 15:49:19 +0800 Subject: [PATCH 08/84] change CreatePR.ps1 for test --- tools/Github/CreatePR.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 5214a699d282..e88f6e35102f 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,4 +64,4 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file +Invoke-WebRequest -Uri https://api.github.com/repos/xtR0d666/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From c91b484d9f45ea60b410df4536c1354beb4d17c9 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 16:18:07 +0800 Subject: [PATCH 09/84] correct ParseWiki2Json.ps1 --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/ParseWiki2Json.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index de8d29837c7c..a976231a7988 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -17,7 +17,7 @@ jobs: displayName: Update fabricbot.json file locally - task: PowerShell@2 - displayName: Commit and push + displayName: Git commit and push inputs: targetType: inline script: | diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index eec54c653f50..82fcbceab90e 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -65,7 +65,7 @@ $whole_json.tasks | ForEach-Object { if ($entry.Value -eq "") { continue } - $labels = @("Service Attention!!!!!!", $entry.Key) + $labels = @("Service Attention", $entry.Key) $mentionees = @($entry.Value -split "," | ForEach-Object { $_.Trim() }) $item = [PSCustomObject]@{ labels = $labels From 59a49c5c003d3bc5fd11aa31e41180a840c8f8f3 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 16:40:45 +0800 Subject: [PATCH 10/84] remove unnecessary output --- tools/Github/ParseWiki2Json.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index 82fcbceab90e..0e48e06fe3c3 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -33,7 +33,6 @@ $headers = @{ } $response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers -Write-Host $response $rows = ($response.content -split "\n") | Select-Object -Skip 6 $aliases = [System.Collections.SortedList]::new() @@ -56,9 +55,9 @@ foreach ($item in $rows) } # change json file -$whole_json = Get-Content -Raw -Path .github/fabricbot.json | ConvertFrom-Json +$WholeJson = Get-Content -Raw -Path .github/fabricbot.json | ConvertFrom-Json -$whole_json.tasks | ForEach-Object { +$WholeJson.tasks | ForEach-Object { if($_.taskType -eq 'scheduledAndTrigger') { $labelsAndMentionsArrayList = New-Object System.Collections.ArrayList foreach ($entry in $aliases.GetEnumerator()) { @@ -77,4 +76,4 @@ $whole_json.tasks | ForEach-Object { } } -($whole_json | ConvertTo-Json -Depth 32) | Out-File -FilePath .github/fabricbot.json +($WholeJson | ConvertTo-Json -Depth 32) | Out-File -FilePath .github/fabricbot.json From d5e453e141e7030a450c5c192a7548c8a751eb48 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 17:05:36 +0800 Subject: [PATCH 11/84] remove quote --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index 0e48e06fe3c3..9e5fa773ab53 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -24,7 +24,7 @@ param( # get wiki content $username="" -$password='$AzureToken' +$password=$AzureToken $pair="{0}:{1}" -f ($username,$password) $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $token = [System.Convert]::ToBase64String($bytes) From cf4bc10306b60807b8497fadd0991682cff0bcde Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 17:23:01 +0800 Subject: [PATCH 12/84] finish test, change back to Azure repo --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index a976231a7988..6fff4a9a9c04 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -29,7 +29,7 @@ jobs: git add . git commit -m "Use pipeline to sync fabricbot22.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin Will_change_fabricbot --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index e88f6e35102f..5214a699d282 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,4 +64,4 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -Invoke-WebRequest -Uri https://api.github.com/repos/xtR0d666/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file +Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From 17b5be61c0137f2bea8072efa3bcdfc91ab23f2b Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 17:26:23 +0800 Subject: [PATCH 13/84] change branch name --- .azure-pipelines/sync-aliases.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 6fff4a9a9c04..efbd87e4cc3f 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -24,17 +24,17 @@ jobs: git pull origin main git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" - git checkout -b "Will_change_fabricbot" + git checkout -b "Change_fabricbot.json_aliases" git add . git commit -m "Use pipeline to sync fabricbot22.json" git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; - git push origin Will_change_fabricbot --force + git push origin Change_fabricbot.json_aliases --force - pwsh: | $Title = "Change Fabricbot.json According To Wiki Page" - $HeadBranch = "Will_change_fabricbot" + $HeadBranch = "Change_fabricbot.json_aliases" $BaseBranch = "main" $Description = "Use powershell to sort taskType: scheduledAndTrigger part of fabricbot.json according to table of Service-Team-Label-and-Contact-List in wiki page" ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description From 11eccd6dcbe68fe53145c4e23a309e903e5b2f4d Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 1 Feb 2023 18:05:28 +0800 Subject: [PATCH 14/84] change some names --- .azure-pipelines/sync-aliases.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index efbd87e4cc3f..bccaccc74ed4 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -9,7 +9,7 @@ trigger: none jobs: - job: UpdateJson - displayName: Update Json + displayName: Update fabricbot.json steps: - checkout: self - pwsh: | @@ -24,19 +24,19 @@ jobs: git pull origin main git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" - git checkout -b "Change_fabricbot.json_aliases" + git checkout -b "internal/sync-fabricbot-json" git add . git commit -m "Use pipeline to sync fabricbot22.json" git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; - git push origin Change_fabricbot.json_aliases --force + git push origin internal/sync-fabricbot-json --force - pwsh: | - $Title = "Change Fabricbot.json According To Wiki Page" - $HeadBranch = "Change_fabricbot.json_aliases" + $Title = "Sync fabricbot.json According To ADO Wiki Page" + $HeadBranch = "internal/sync-fabricbot-json" $BaseBranch = "main" - $Description = "Use powershell to sort taskType: scheduledAndTrigger part of fabricbot.json according to table of Service-Team-Label-and-Contact-List in wiki page" + $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description displayName: Create PR to main branch \ No newline at end of file From bb4d892f20f7393c5f12e0254dbf97f24f8ff714 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 13:09:34 +0800 Subject: [PATCH 15/84] remove the use of magic number --- .azure-pipelines/sync-aliases.yml | 4 ++-- tools/Github/ParseWiki2Json.ps1 | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index bccaccc74ed4..080a1c470843 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,4 +1,4 @@ -# Variable 'AzureToken' and 'BotAccessToken' was defined in the Variables tab +# Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab resources: repositories: - repository: self @@ -13,7 +13,7 @@ jobs: steps: - checkout: self - pwsh: | - ./tools/Github/ParseWiki2Json.ps1 -AzureToken $(AzureToken) + ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally - task: PowerShell@2 diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index 9e5fa773ab53..b0c3ae276040 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -19,12 +19,12 @@ #> param( [Parameter(Mandatory = $true)] - [string]$AzureToken + [string]$ADOToken ) # get wiki content $username="" -$password=$AzureToken +$password=$ADOToken $pair="{0}:{1}" -f ($username,$password) $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $token = [System.Convert]::ToBase64String($bytes) @@ -34,7 +34,7 @@ $headers = @{ $response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers -$rows = ($response.content -split "\n") | Select-Object -Skip 6 +$rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() foreach ($item in $rows) From 5b248b324e204e3b4b8495b1199b9b9205b39f68 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 13:14:53 +0800 Subject: [PATCH 16/84] change commit message --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 080a1c470843..5b3a9853d3a7 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -27,7 +27,7 @@ jobs: git checkout -b "internal/sync-fabricbot-json" git add . - git commit -m "Use pipeline to sync fabricbot22.json" + git commit -m "Sync fabricbot22.json" git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force From 91438f750ea5ec211ec8489d985bd2328baa954e Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 14:09:38 +0800 Subject: [PATCH 17/84] remove redundant git pull --- .azure-pipelines/sync-aliases.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 5b3a9853d3a7..89e29a5a2c13 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -21,7 +21,6 @@ jobs: inputs: targetType: inline script: | - git pull origin main git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" git checkout -b "internal/sync-fabricbot-json" From dc0e489d7b6b7a551b20430ac0b0fcc00cf65bf3 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 14:22:53 +0800 Subject: [PATCH 18/84] change the way of getting wiki content --- tools/Github/ParseWiki2Json.ps1 | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index b0c3ae276040..8aa631a2d513 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -22,19 +22,24 @@ param( [string]$ADOToken ) -# get wiki content -$username="" -$password=$ADOToken -$pair="{0}:{1}" -f ($username,$password) -$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) -$token = [System.Convert]::ToBase64String($bytes) -$headers = @{ - Authorization = "Basic {0}" -f ($token) -} +# # get wiki content +# $username="" +# $password=$ADOToken +# $pair="{0}:{1}" -f ($username,$password) +# $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) +# $token = [System.Convert]::ToBase64String($bytes) +# $headers = @{ +# Authorization = "Basic {0}" -f ($token) +# } + +# $response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers + +# $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 -$response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers +git clone https://azure-sdk@dev.azure.com/azure-sdk/internal/_git/internal.wiki +$wikiContent = Get-Content -Raw -Path internal.wiki/Engineering\ System/GitHub\ Repos/Issue\ Management/Service\ Team\ Label\ and\ Contact\ List +$rows = ($wikiContent -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 -$rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() foreach ($item in $rows) From b5e6f7e7f56f4c3ea5561445992882269a160365 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 15:51:14 +0800 Subject: [PATCH 19/84] change space to - --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index 8aa631a2d513..e98edc8e2a96 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -37,7 +37,7 @@ param( # $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 git clone https://azure-sdk@dev.azure.com/azure-sdk/internal/_git/internal.wiki -$wikiContent = Get-Content -Raw -Path internal.wiki/Engineering\ System/GitHub\ Repos/Issue\ Management/Service\ Team\ Label\ and\ Contact\ List +$wikiContent = Get-Content -Raw -Path internal.wiki/Engineering-System/GitHub-Repos/Issue-Management/Service-Team-Label-and-Contact-List $rows = ($wikiContent -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() From 0d2bbff7884fe3dd2701589d76ebec840b7dd514 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 15:54:59 +0800 Subject: [PATCH 20/84] add md --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index e98edc8e2a96..f5eb0e1bc756 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -37,7 +37,7 @@ param( # $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 git clone https://azure-sdk@dev.azure.com/azure-sdk/internal/_git/internal.wiki -$wikiContent = Get-Content -Raw -Path internal.wiki/Engineering-System/GitHub-Repos/Issue-Management/Service-Team-Label-and-Contact-List +$wikiContent = Get-Content -Raw -Path internal.wiki/Engineering-System/GitHub-Repos/Issue-Management/Service-Team-Label-and-Contact-List.md $rows = ($wikiContent -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() From affdb10ce28475c0dc4da1e6bf11c74bb7bab758 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 16:01:07 +0800 Subject: [PATCH 21/84] set current dir --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index f5eb0e1bc756..b96f7f252817 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -37,7 +37,7 @@ param( # $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 git clone https://azure-sdk@dev.azure.com/azure-sdk/internal/_git/internal.wiki -$wikiContent = Get-Content -Raw -Path internal.wiki/Engineering-System/GitHub-Repos/Issue-Management/Service-Team-Label-and-Contact-List.md +$wikiContent = Get-Content -Raw -Path ./internal.wiki/Engineering-System/GitHub-Repos/Issue-Management/Service-Team-Label-and-Contact-List.md $rows = ($wikiContent -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() From ab482d1debd9ff0c5d21ac52a7e762fbf220dac6 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 16:04:26 +0800 Subject: [PATCH 22/84] use space --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index b96f7f252817..01af66742336 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -37,7 +37,7 @@ param( # $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 git clone https://azure-sdk@dev.azure.com/azure-sdk/internal/_git/internal.wiki -$wikiContent = Get-Content -Raw -Path ./internal.wiki/Engineering-System/GitHub-Repos/Issue-Management/Service-Team-Label-and-Contact-List.md +$wikiContent = Get-Content -Raw -Path './internal.wiki/Engineering System/GitHub Repos/Issue Management/Service Team Label and Contact List.md' $rows = ($wikiContent -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() From 59d5cd65a5ed47fa5ba0e45d29c4e185a079dd31 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 16:10:02 +0800 Subject: [PATCH 23/84] use - --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index 01af66742336..b96f7f252817 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -37,7 +37,7 @@ param( # $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 git clone https://azure-sdk@dev.azure.com/azure-sdk/internal/_git/internal.wiki -$wikiContent = Get-Content -Raw -Path './internal.wiki/Engineering System/GitHub Repos/Issue Management/Service Team Label and Contact List.md' +$wikiContent = Get-Content -Raw -Path ./internal.wiki/Engineering-System/GitHub-Repos/Issue-Management/Service-Team-Label-and-Contact-List.md $rows = ($wikiContent -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() From 5d90c4b069023a75b1926a35844771e30e0e2c14 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 16:47:56 +0800 Subject: [PATCH 24/84] still use ADOToken --- tools/Github/ParseWiki2Json.ps1 | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index b96f7f252817..d9442fbd808d 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -22,24 +22,18 @@ param( [string]$ADOToken ) -# # get wiki content -# $username="" -# $password=$ADOToken -# $pair="{0}:{1}" -f ($username,$password) -# $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) -# $token = [System.Convert]::ToBase64String($bytes) -# $headers = @{ -# Authorization = "Basic {0}" -f ($token) -# } - -# $response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers - -# $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 - -git clone https://azure-sdk@dev.azure.com/azure-sdk/internal/_git/internal.wiki -$wikiContent = Get-Content -Raw -Path ./internal.wiki/Engineering-System/GitHub-Repos/Issue-Management/Service-Team-Label-and-Contact-List.md -$rows = ($wikiContent -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 +# get wiki content +$username="" +$password=$ADOToken +$pair="{0}:{1}" -f ($username,$password) +$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) +$token = [System.Convert]::ToBase64String($bytes) +$headers = @{ + Authorization = "Basic {0}" -f ($token) +} +$response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers +$rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() foreach ($item in $rows) From 635afa3188102fa93421783c7dd1858075865358 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 17:01:53 +0800 Subject: [PATCH 25/84] use a better wiki url --- tools/Github/ParseWiki2Json.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index d9442fbd808d..1be1bc127a8f 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -32,7 +32,7 @@ $headers = @{ Authorization = "Basic {0}" -f ($token) } -$response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?api-version=7.1-preview.1&path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers +$response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List' -Headers $headers $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() From bcec48e0b121345296c4a491620f0102f01311d0 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 19:57:10 +0800 Subject: [PATCH 26/84] test purpose --- .azure-pipelines/sync-aliases.yml | 10 +--------- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 89e29a5a2c13..df331eb412b8 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,12 +1,4 @@ # Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab -resources: - repositories: - - repository: self - type: git - ref: main - -trigger: none - jobs: - job: UpdateJson displayName: Update fabricbot.json @@ -28,7 +20,7 @@ jobs: git add . git commit -m "Sync fabricbot22.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 5214a699d282..e88f6e35102f 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,4 +64,4 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file +Invoke-WebRequest -Uri https://api.github.com/repos/xtR0d666/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From 0eef6bbbea01f47f4b7482c24507c364a6fee6bb Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 20:01:31 +0800 Subject: [PATCH 27/84] test2 --- .azure-pipelines/sync-aliases.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index df331eb412b8..e06a7cc64b4d 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,4 +1,10 @@ # Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab +resources: + repositories: + - repository: self + type: git + ref: main + jobs: - job: UpdateJson displayName: Update fabricbot.json From fabc2b92f2dc054ffffbe3088597695250902990 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 20:14:55 +0800 Subject: [PATCH 28/84] test oauth --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index e06a7cc64b4d..337e49d9c880 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot22.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken):x-oauth-basic@github.com/xtR0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | From 60c55cb117dc08005ee38552a5bf4758b0cdeb73 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 20:37:51 +0800 Subject: [PATCH 29/84] test3 --- .azure-pipelines/sync-aliases.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 337e49d9c880..3fcc522d864a 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -19,6 +19,7 @@ jobs: inputs: targetType: inline script: | + git pull origin main git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" git checkout -b "internal/sync-fabricbot-json" @@ -26,7 +27,7 @@ jobs: git add . git commit -m "Sync fabricbot22.json" - git remote set-url origin https://$(BotAccessToken):x-oauth-basic@github.com/xtR0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | From d796b9da99fa3e656679498f64f49ca20fa994ea Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 2 Feb 2023 22:00:21 +0800 Subject: [PATCH 30/84] finish test --- .azure-pipelines/sync-aliases.yml | 9 +-------- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 3fcc522d864a..fc06684c96e8 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,10 +1,4 @@ # Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab -resources: - repositories: - - repository: self - type: git - ref: main - jobs: - job: UpdateJson displayName: Update fabricbot.json @@ -19,7 +13,6 @@ jobs: inputs: targetType: inline script: | - git pull origin main git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" git checkout -b "internal/sync-fabricbot-json" @@ -27,7 +20,7 @@ jobs: git add . git commit -m "Sync fabricbot22.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index e88f6e35102f..5214a699d282 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,4 +64,4 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -Invoke-WebRequest -Uri https://api.github.com/repos/xtR0d666/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file +Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From fdf250ca8ce0522188bf3ab9f7a70c8af578a5e5 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Sun, 5 Feb 2023 18:11:28 +0800 Subject: [PATCH 31/84] test again --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index fc06684c96e8..df331eb412b8 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -20,7 +20,7 @@ jobs: git add . git commit -m "Sync fabricbot22.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 5214a699d282..e88f6e35102f 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,4 +64,4 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file +Invoke-WebRequest -Uri https://api.github.com/repos/xtR0d666/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From 198f2b09c67a34c2669b25433563976a7dc3976a Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Mon, 6 Feb 2023 09:40:38 +0800 Subject: [PATCH 32/84] test --- .azure-pipelines/sync-aliases.yml | 1 - tools/Github/ParseWiki2Json.ps1 | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index df331eb412b8..40a37e05c9e1 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -3,7 +3,6 @@ jobs: - job: UpdateJson displayName: Update fabricbot.json steps: - - checkout: self - pwsh: | ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index 1be1bc127a8f..b924a5ba3cfa 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -32,7 +32,7 @@ $headers = @{ Authorization = "Basic {0}" -f ($token) } -$response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List' -Headers $headers +$response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers $rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() From 51fffc1ef8a9ef9bc1abae83e0ef550eab4c071d Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Mon, 6 Feb 2023 10:14:45 +0800 Subject: [PATCH 33/84] finish test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 40a37e05c9e1..fb5de8b2453e 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -19,7 +19,7 @@ jobs: git add . git commit -m "Sync fabricbot22.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index e88f6e35102f..5214a699d282 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,4 +64,4 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -Invoke-WebRequest -Uri https://api.github.com/repos/xtR0d666/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file +Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From ed35c0ed1399593f1b281880a2147393375678a4 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Mon, 6 Feb 2023 15:58:41 +0800 Subject: [PATCH 34/84] test cron --- .azure-pipelines/sync-aliases.yml | 11 +++++++++-- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index fb5de8b2453e..f07aa34100a0 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,4 +1,11 @@ # Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab +schedules: +- cron: "50 23 * * *" + displayName: 11:50 PM (UTC + 8:00) China Daily Build + branches: + include: + - main + jobs: - job: UpdateJson displayName: Update fabricbot.json @@ -17,9 +24,9 @@ jobs: git checkout -b "internal/sync-fabricbot-json" git add . - git commit -m "Sync fabricbot22.json" + git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 5214a699d282..e88f6e35102f 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,4 +64,4 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file +Invoke-WebRequest -Uri https://api.github.com/repos/xtR0d666/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From 0f4ae7c65001795bdec0ed0c1a7c26456e8b67bf Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Mon, 6 Feb 2023 16:14:16 +0800 Subject: [PATCH 35/84] test double pr --- tools/Github/CreatePR.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index e88f6e35102f..d647c2264f0b 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,4 +64,11 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -Invoke-WebRequest -Uri https://api.github.com/repos/xtR0d666/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file +$Uri = "https://api.github.com/repos/xtR0d666/azure-powershell/pulls" +$PullRequests = Invoke-WebRequest -Uri $Uri -Headers $Headers | ConvertFrom-Json +$ExistingPr = $PullRequests | Where-Object { $_.title -eq $Title } +if ($ExistingPr) { + Write-Host "The PR named $Title already exists" + exit 0 +} +Invoke-WebRequest -Uri $Uri -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From b1924f22cbbc46de9b2bbeb681e923eefaa6188e Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Mon, 6 Feb 2023 16:26:59 +0800 Subject: [PATCH 36/84] solve double pr --- .azure-pipelines/sync-aliases.yml | 4 ++-- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index f07aa34100a0..fbd4e744ce82 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,6 +1,6 @@ # Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab schedules: -- cron: "50 23 * * *" +- cron: "50 15 * * *" displayName: 11:50 PM (UTC + 8:00) China Daily Build branches: include: @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index d647c2264f0b..d7574af8c558 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -64,7 +64,7 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/xtR0d666/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" $PullRequests = Invoke-WebRequest -Uri $Uri -Headers $Headers | ConvertFrom-Json $ExistingPr = $PullRequests | Where-Object { $_.title -eq $Title } if ($ExistingPr) { From d323d0d2f29eee7a477f66ef59d0f1216636604a Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 7 Feb 2023 16:58:46 +0800 Subject: [PATCH 37/84] test --- .azure-pipelines/sync-aliases.yml | 4 ++-- tools/Github/CreatePR.ps1 | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index fbd4e744ce82..69c6c4ea6ba7 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,7 +1,7 @@ # Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab schedules: - cron: "50 15 * * *" - displayName: 11:50 PM (UTC + 8:00) China Daily Build + displayName: 11:50 PM (UTC + 8:00) China Daily Run branches: include: - main @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index d7574af8c558..37e131c81e8e 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -31,7 +31,9 @@ param( [string]$BaseBranch, [Parameter(Mandatory = $false)] - [string]$Description + [string]$Description, + + [switch]$FailOnPRExisted = $false ) $Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $BotAccessToken"} @@ -64,11 +66,17 @@ $Description * **SHOULD NOT** adjust version of module manually in pull request "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" + +$Uri = "https://api.github.com/repos/xtR0d666/azure-powershell/pulls" $PullRequests = Invoke-WebRequest -Uri $Uri -Headers $Headers | ConvertFrom-Json $ExistingPr = $PullRequests | Where-Object { $_.title -eq $Title } + +if ($ExistingPr -and $FailOnPRExisted) { + Write-Error "The PR named $Title already exists." + exit 1 +} if ($ExistingPr) { - Write-Host "The PR named $Title already exists" + Write-Host "The PR named $Title already exists. Skipping creation because FailOnPRExisted is set to $FailOnPRExisted." exit 0 } Invoke-WebRequest -Uri $Uri -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file From d5ac369a8e3f3a7cc70e5124e7631e820f0d6a37 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 7 Feb 2023 17:03:18 +0800 Subject: [PATCH 38/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 69c6c4ea6ba7..596bddedc43d 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -34,6 +34,6 @@ jobs: $HeadBranch = "internal/sync-fabricbot-json" $BaseBranch = "main" $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" - ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description + ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description -FailOnPRExisted displayName: Create PR to main branch \ No newline at end of file From e663991089cf701389385bbd72846f72ad5f1da3 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 7 Feb 2023 17:06:01 +0800 Subject: [PATCH 39/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 596bddedc43d..69c6c4ea6ba7 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -34,6 +34,6 @@ jobs: $HeadBranch = "internal/sync-fabricbot-json" $BaseBranch = "main" $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" - ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description -FailOnPRExisted + ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description displayName: Create PR to main branch \ No newline at end of file From 95ff796696ca896d17db3a93d0fd123c9372fc07 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 7 Feb 2023 17:09:29 +0800 Subject: [PATCH 40/84] finish test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 69c6c4ea6ba7..3a23dc628122 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtR0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 37e131c81e8e..3381dc19d2d1 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -67,7 +67,7 @@ $Description "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/xtR0d666/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" $PullRequests = Invoke-WebRequest -Uri $Uri -Headers $Headers | ConvertFrom-Json $ExistingPr = $PullRequests | Where-Object { $_.title -eq $Title } From 2d350cb3a1a4d2b3cba539c622c619de16167428 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 7 Feb 2023 17:34:09 +0800 Subject: [PATCH 41/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 3a23dc628122..ed252d85ac04 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 3381dc19d2d1..a97acec490c4 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -36,7 +36,7 @@ param( [switch]$FailOnPRExisted = $false ) -$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $BotAccessToken"} +$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $BotAccessToken" } $PrBody = @" @@ -65,18 +65,24 @@ $Description * **SHOULD NOT** introduce [breaking changes](../blob/main/documentation/breaking-changes/breaking-changes-definition.md) in Az minor release except preview version. * **SHOULD NOT** adjust version of module manually in pull request "@ + $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" $PullRequests = Invoke-WebRequest -Uri $Uri -Headers $Headers | ConvertFrom-Json -$ExistingPr = $PullRequests | Where-Object { $_.title -eq $Title } +$ExistingPr = $PullRequests | Where-Object { $_.head.ref -eq $HeadBranch -and $_.base.ref -eq $BaseBranch } -if ($ExistingPr -and $FailOnPRExisted) { +if (!$ExistingPr) { + Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) + exit 0 +} + +if ($FailOnPRExisted) { Write-Error "The PR named $Title already exists." exit 1 } -if ($ExistingPr) { +else { Write-Host "The PR named $Title already exists. Skipping creation because FailOnPRExisted is set to $FailOnPRExisted." exit 0 } -Invoke-WebRequest -Uri $Uri -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) \ No newline at end of file + From 9bc5aabfb2dd14bcf035c4659d843eb6418bd8f2 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 7 Feb 2023 17:41:18 +0800 Subject: [PATCH 42/84] finish test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index ed252d85ac04..3a23dc628122 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index a97acec490c4..4b23ad2df56d 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -67,8 +67,8 @@ $Description "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } +$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" -$Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" $PullRequests = Invoke-WebRequest -Uri $Uri -Headers $Headers | ConvertFrom-Json $ExistingPr = $PullRequests | Where-Object { $_.head.ref -eq $HeadBranch -and $_.base.ref -eq $BaseBranch } From 2c5648db40401cd763df7307b4923a406515f659 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 10:46:23 +0800 Subject: [PATCH 43/84] test restapi --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 3a23dc628122..ed252d85ac04 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 4b23ad2df56d..e6d9bd0b724c 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -67,12 +67,11 @@ $Description "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" -$PullRequests = Invoke-WebRequest -Uri $Uri -Headers $Headers | ConvertFrom-Json -$ExistingPr = $PullRequests | Where-Object { $_.head.ref -eq $HeadBranch -and $_.base.ref -eq $BaseBranch } - -if (!$ExistingPr) { +&PrUrl = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls?head=$HeadBranch&base=$BaseBranch" +$PullRequests = Invoke-RestMethod -Uri $PrUrl -Method GET -Headers $Headers +if (!$PullRequests) { Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) exit 0 } From e829d30227659046dbbd792f93950084a16b13c7 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 11:16:12 +0800 Subject: [PATCH 44/84] te --- tools/Github/CreatePR.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index e6d9bd0b724c..a8d4bdb2eacc 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -69,8 +69,8 @@ $Description $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } $Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" -&PrUrl = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls?head=$HeadBranch&base=$BaseBranch" -$PullRequests = Invoke-RestMethod -Uri $PrUrl -Method GET -Headers $Headers +$PrHead = @{"Accept" = "application/vnd.github+json"; "head" = $HeadBranch; "base" = $BaseBranch } +$PullRequests = Invoke-RestMethod -Uri $Uri -Method GET -Headers $PrHead if (!$PullRequests) { Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) exit 0 From e603ebba705721a5ba704a4d0c9b1d0d95262d3e Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 11:21:34 +0800 Subject: [PATCH 45/84] finish test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index ed252d85ac04..3a23dc628122 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index a8d4bdb2eacc..6e45d77641eb 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -67,7 +67,7 @@ $Description "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" $PrHead = @{"Accept" = "application/vnd.github+json"; "head" = $HeadBranch; "base" = $BaseBranch } $PullRequests = Invoke-RestMethod -Uri $Uri -Method GET -Headers $PrHead From 878e7816f24caef3895658e7e746581909728620 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 14:02:59 +0800 Subject: [PATCH 46/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 3a23dc628122..ed252d85ac04 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 6e45d77641eb..3920429e58ef 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -67,11 +67,11 @@ $Description "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" $PrHead = @{"Accept" = "application/vnd.github+json"; "head" = $HeadBranch; "base" = $BaseBranch } $PullRequests = Invoke-RestMethod -Uri $Uri -Method GET -Headers $PrHead -if (!$PullRequests) { +if ($PullRequests.Length -eq 0) { Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) exit 0 } From 077a711c5a918bf5678825fe48972acab471ef5c Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 14:09:54 +0800 Subject: [PATCH 47/84] finish test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index ed252d85ac04..3a23dc628122 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 3920429e58ef..47c7d0947017 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -67,7 +67,7 @@ $Description "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" $PrHead = @{"Accept" = "application/vnd.github+json"; "head" = $HeadBranch; "base" = $BaseBranch } $PullRequests = Invoke-RestMethod -Uri $Uri -Method GET -Headers $PrHead From 9681afbb10f4bc0fb25ee07c78f637d89bff2cbd Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 17:15:09 +0800 Subject: [PATCH 48/84] filter pr --- tools/Github/CreatePR.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 47c7d0947017..e9ee49a353ab 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -69,8 +69,8 @@ $Description $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } $Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" -$PrHead = @{"Accept" = "application/vnd.github+json"; "head" = $HeadBranch; "base" = $BaseBranch } -$PullRequests = Invoke-RestMethod -Uri $Uri -Method GET -Headers $PrHead +$PrUri = "https://api.github.com/repos/Azure/azure-powershell/pulls?head=Azure:$HeadBranch&base=$BaseBranch" +$PullRequests = Invoke-RestMethod -Uri $PrUri -Method GET -Headers $PrHead if ($PullRequests.Length -eq 0) { Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) exit 0 From 40f8997bc4b709d94f74462e6eaf6b13b28822a1 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 17:23:50 +0800 Subject: [PATCH 49/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 4 ++-- tools/Github/ParseWiki2Json.ps1 | 24 ++++++++++-------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 3a23dc628122..ed252d85ac04 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index e9ee49a353ab..745f473391b4 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -69,8 +69,8 @@ $Description $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } $Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" -$PrUri = "https://api.github.com/repos/Azure/azure-powershell/pulls?head=Azure:$HeadBranch&base=$BaseBranch" -$PullRequests = Invoke-RestMethod -Uri $PrUri -Method GET -Headers $PrHead +$PrUri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls?head=Azure:$HeadBranch&base=$BaseBranch" +$PullRequests = Invoke-RestMethod -Uri $PrUri -Method GET -Headers $Headers if ($PullRequests.Length -eq 0) { Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) exit 0 diff --git a/tools/Github/ParseWiki2Json.ps1 b/tools/Github/ParseWiki2Json.ps1 index b924a5ba3cfa..c80ea2094335 100644 --- a/tools/Github/ParseWiki2Json.ps1 +++ b/tools/Github/ParseWiki2Json.ps1 @@ -23,9 +23,9 @@ param( ) # get wiki content -$username="" -$password=$ADOToken -$pair="{0}:{1}" -f ($username,$password) +$username = "" +$password = $ADOToken +$pair = "{0}:{1}" -f ($username, $password) $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $token = [System.Convert]::ToBase64String($bytes) $headers = @{ @@ -33,21 +33,17 @@ $headers = @{ } $response = Invoke-RestMethod 'https://dev.azure.com/azure-sdk/internal/_apis/wiki/wikis/internal.wiki/pages?path=/Engineering%20System/GitHub%20Repos/Issue%20Management/Service%20Team%20Label%20and%20Contact%20List&includeContent=True' -Headers $headers -$rows = ($response.content -split "\n") | Where-Object { $_ -like '|*'} | Select-Object -Skip 2 +$rows = ($response.content -split "\n") | Where-Object { $_ -like '|*' } | Select-Object -Skip 2 $aliases = [System.Collections.SortedList]::new() -foreach ($item in $rows) -{ +foreach ($item in $rows) { $list = $item -split "\|" if ($list.Count -eq 1) { continue } - if ($list[1].Trim().Length -gt 0) - { - if ($list.Count -gt 3) - { + if ($list[1].Trim().Length -gt 0) { + if ($list.Count -gt 3) { $aliases.Add($list[1].Trim(), $list[3].Trim()) } - else - { + else { $aliases.Add($list[1].Trim(), "") } } @@ -57,7 +53,7 @@ foreach ($item in $rows) $WholeJson = Get-Content -Raw -Path .github/fabricbot.json | ConvertFrom-Json $WholeJson.tasks | ForEach-Object { - if($_.taskType -eq 'scheduledAndTrigger') { + if ($_.taskType -eq 'scheduledAndTrigger') { $labelsAndMentionsArrayList = New-Object System.Collections.ArrayList foreach ($entry in $aliases.GetEnumerator()) { if ($entry.Value -eq "") { @@ -66,7 +62,7 @@ $WholeJson.tasks | ForEach-Object { $labels = @("Service Attention", $entry.Key) $mentionees = @($entry.Value -split "," | ForEach-Object { $_.Trim() }) $item = [PSCustomObject]@{ - labels = $labels + labels = $labels mentionees = $mentionees } [void]$labelsAndMentionsArrayList.Add($item) From 1b3634ad12842664ffee21bb3594f8281296f023 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 17:34:02 +0800 Subject: [PATCH 50/84] test --- tools/Github/CreatePR.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 745f473391b4..c07ee068d271 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -67,7 +67,7 @@ $Description "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" $PrUri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls?head=Azure:$HeadBranch&base=$BaseBranch" $PullRequests = Invoke-RestMethod -Uri $PrUri -Method GET -Headers $Headers From 734537a5787fe940e19c3986913be36226142fb0 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 17:49:04 +0800 Subject: [PATCH 51/84] test --- tools/Github/CreatePR.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index c07ee068d271..f89e16a00921 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -69,7 +69,7 @@ $Description $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } $Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" -$PrUri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls?head=Azure:$HeadBranch&base=$BaseBranch" +$PrUri = "$Uri?head=xtr0d666:$HeadBranch&base=$BaseBranch" $PullRequests = Invoke-RestMethod -Uri $PrUri -Method GET -Headers $Headers if ($PullRequests.Length -eq 0) { Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) From 72f6684ee1a0e8e76e876b8ecb8972b706f3b7a4 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 18:02:12 +0800 Subject: [PATCH 52/84] test --- tools/Github/CreatePR.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index f89e16a00921..022ff14de99a 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -69,7 +69,7 @@ $Description $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } $Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" -$PrUri = "$Uri?head=xtr0d666:$HeadBranch&base=$BaseBranch" +$PrUri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls?head=xtr0d666:$HeadBranch&base=$BaseBranch" $PullRequests = Invoke-RestMethod -Uri $PrUri -Method GET -Headers $Headers if ($PullRequests.Length -eq 0) { Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) From 1c4b9f3ee7a853b764f463240a3fdebdcd7cff2c Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 8 Feb 2023 18:05:51 +0800 Subject: [PATCH 53/84] finish test --- .azure-pipelines/sync-aliases.yml | 2 +- tools/Github/CreatePR.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index ed252d85ac04..3a23dc628122 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -26,7 +26,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force - pwsh: | diff --git a/tools/Github/CreatePR.ps1 b/tools/Github/CreatePR.ps1 index 022ff14de99a..874e3d434b51 100644 --- a/tools/Github/CreatePR.ps1 +++ b/tools/Github/CreatePR.ps1 @@ -67,9 +67,9 @@ $Description "@ $RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch } -$Uri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls" +$Uri = "https://api.github.com/repos/Azure/azure-powershell/pulls" -$PrUri = "https://api.github.com/repos/xtr0d666/azure-powershell/pulls?head=xtr0d666:$HeadBranch&base=$BaseBranch" +$PrUri = "https://api.github.com/repos/Azure/azure-powershell/pulls?head=Azure:$HeadBranch&base=$BaseBranch" $PullRequests = Invoke-RestMethod -Uri $PrUri -Method GET -Headers $Headers if ($PullRequests.Length -eq 0) { Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) From 9537c331f30764dc939ef45dd8b21e38ca308da4 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 14 Feb 2023 11:47:12 +0800 Subject: [PATCH 54/84] Solve pipeline error when no changes --- .azure-pipelines/sync-aliases.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 3a23dc628122..f425f29dbee1 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -30,10 +30,15 @@ jobs: git push origin internal/sync-fabricbot-json --force - pwsh: | - $Title = "Sync fabricbot.json According To ADO Wiki Page" - $HeadBranch = "internal/sync-fabricbot-json" - $BaseBranch = "main" - $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" - ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description + $diff = git diff main..internal/sync-fabricbot-json + if ($diff.Length -eq 0) { + Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." + } else { + $Title = "Sync fabricbot.json According To ADO Wiki Page" + $HeadBranch = "internal/sync-fabricbot-json" + $BaseBranch = "main" + $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" + ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description + } displayName: Create PR to main branch \ No newline at end of file From 6daa93769cb62ba1eb9590b18f621b560ae49e54 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 14 Feb 2023 11:52:21 +0800 Subject: [PATCH 55/84] add newline at end of file --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index f425f29dbee1..a880269542d3 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -41,4 +41,4 @@ jobs: ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description } displayName: Create PR to main branch - \ No newline at end of file + \ No newline at end of file From 730d05ea703f777cd7ad33cfbb7eb63ae0cd840a Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Tue, 14 Feb 2023 11:54:53 +0800 Subject: [PATCH 56/84] change to pwsh --- .azure-pipelines/sync-aliases.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index a880269542d3..763913fe6b99 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -14,20 +14,17 @@ jobs: ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally - - task: PowerShell@2 - displayName: Git commit and push - inputs: - targetType: inline - script: | - git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" - git config --global user.name "azure-powershell-bot" - git checkout -b "internal/sync-fabricbot-json" + - pwsh: | + git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" + git config --global user.name "azure-powershell-bot" + git checkout -b "internal/sync-fabricbot-json" - git add . - git commit -m "Sync fabricbot.json" + git add . + git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/Azure/azure-powershell.git; - git push origin internal/sync-fabricbot-json --force + git remote set-url origin https://azure-powershell-bot:$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git push origin internal/sync-fabricbot-json --force + displayName: Git commit and push - pwsh: | $diff = git diff main..internal/sync-fabricbot-json From 219bc141f2c782ca2f237273f183d1075ba5fd3c Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:04:24 +0800 Subject: [PATCH 57/84] test diff --- .azure-pipelines/sync-aliases.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 763913fe6b99..8c10b3eadd33 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -22,7 +22,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://azure-powershell-bot:$(BotAccessToken)@github.com/Azure/azure-powershell.git; + git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force displayName: Git commit and push @@ -31,6 +31,8 @@ jobs: if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { + Write-Host "you differences" + exit 0; $Title = "Sync fabricbot.json According To ADO Wiki Page" $HeadBranch = "internal/sync-fabricbot-json" $BaseBranch = "main" From 7be2baedb9ee92ddd44c9bdb0bfa659c689129a6 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:09:17 +0800 Subject: [PATCH 58/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index ebf1d70e3336..577db219730f 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -27,7 +27,7 @@ jobs: displayName: Git commit and push - pwsh: | - $diff = git diff main..internal/sync-fabricbot-json + $diff = git diff origin/main..internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 4ef61b5dd03d062304790eb25dfdd842385da67d Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:14:48 +0800 Subject: [PATCH 59/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 577db219730f..f7ac7da1bb84 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -27,7 +27,7 @@ jobs: displayName: Git commit and push - pwsh: | - $diff = git diff origin/main..internal/sync-fabricbot-json + $diff = git diff main.."internal/sync-fabricbot-json" if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From d2a87c5579bc1010737b79acd5c8b0579b8ad471 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:24:30 +0800 Subject: [PATCH 60/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index f7ac7da1bb84..10a25c9adc26 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -27,7 +27,7 @@ jobs: displayName: Git commit and push - pwsh: | - $diff = git diff main.."internal/sync-fabricbot-json" + $diff = git diff main..'internal/sync-fabricbot-json' if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 25ed275dac3b4f141683e2900d156d81878b9719 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:29:45 +0800 Subject: [PATCH 61/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 10a25c9adc26..00447ca27255 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -27,7 +27,7 @@ jobs: displayName: Git commit and push - pwsh: | - $diff = git diff main..'internal/sync-fabricbot-json' + $diff = git diff main internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 1f7bb12eab8b8243f0d6cbc2035f132e2c0c61b4 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:33:17 +0800 Subject: [PATCH 62/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 00447ca27255..8b95d8cda100 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -27,7 +27,7 @@ jobs: displayName: Git commit and push - pwsh: | - $diff = git diff main internal/sync-fabricbot-json + $diff = git diff origin/main internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 4e396ea2b66cf70e24506f8a99a0c20e18ba2cbb Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:38:12 +0800 Subject: [PATCH 63/84] test --- .azure-pipelines/sync-aliases.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 8b95d8cda100..3e467eed098e 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,4 +1,10 @@ # Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab +resources: + repositories: + - repository: self + type: git + ref: main + schedules: - cron: "50 15 * * *" displayName: 11:50 PM (UTC + 8:00) China Daily Run @@ -27,7 +33,7 @@ jobs: displayName: Git commit and push - pwsh: | - $diff = git diff origin/main internal/sync-fabricbot-json + $diff = git diff main internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 10b26859c9f47a347f0a59874c444fdea9fe4f66 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:42:10 +0800 Subject: [PATCH 64/84] test --- .azure-pipelines/sync-aliases.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 3e467eed098e..45ea060c12cc 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -1,10 +1,4 @@ # Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab -resources: - repositories: - - repository: self - type: git - ref: main - schedules: - cron: "50 15 * * *" displayName: 11:50 PM (UTC + 8:00) China Daily Run @@ -33,7 +27,9 @@ jobs: displayName: Git commit and push - pwsh: | + git checkout main $diff = git diff main internal/sync-fabricbot-json + git checkout internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From ff754eba7912494870f76bca426ab02b5852fbb0 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:46:54 +0800 Subject: [PATCH 65/84] test --- .azure-pipelines/sync-aliases.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 45ea060c12cc..17d1211ce160 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -27,6 +27,7 @@ jobs: displayName: Git commit and push - pwsh: | + git branch --list git checkout main $diff = git diff main internal/sync-fabricbot-json git checkout internal/sync-fabricbot-json From cbd15ac351faca3fa64b916fae33af4a692128a7 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:55:52 +0800 Subject: [PATCH 66/84] test --- .azure-pipelines/sync-aliases.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 17d1211ce160..34e508d21882 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -27,10 +27,9 @@ jobs: displayName: Git commit and push - pwsh: | - git branch --list - git checkout main + git remote -v + $diff = git diff main internal/sync-fabricbot-json - git checkout internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From cf5e3cdd06c723095c4bab3a70a05315050474da Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 11:58:48 +0800 Subject: [PATCH 67/84] test --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 34e508d21882..0f0cb3706ca2 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -28,7 +28,7 @@ jobs: - pwsh: | git remote -v - + git branch -vv $diff = git diff main internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." From bfa48f9db4da90c77bddcba1b5708dd6ce382be9 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 13:13:33 +0800 Subject: [PATCH 68/84] test --- .azure-pipelines/sync-aliases.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 0f0cb3706ca2..b1cf48937abb 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -17,6 +17,7 @@ jobs: - pwsh: | git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" + git branch -vv git checkout -b "internal/sync-fabricbot-json" git add . From 6277ae69f9064afdf6fb1bfd8a2387e9fa4fa970 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 13:25:33 +0800 Subject: [PATCH 69/84] test --- .azure-pipelines/sync-aliases.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index b1cf48937abb..6f75e5c471c8 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -17,7 +17,6 @@ jobs: - pwsh: | git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" - git branch -vv git checkout -b "internal/sync-fabricbot-json" git add . @@ -28,9 +27,8 @@ jobs: displayName: Git commit and push - pwsh: | - git remote -v git branch -vv - $diff = git diff main internal/sync-fabricbot-json + $diff = git diff internal/sync-fabricbot-json^ internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 132f64b24f24d3e677a3fc7f0207f0926c8ceee8 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 13:30:14 +0800 Subject: [PATCH 70/84] testt --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 6f75e5c471c8..e4a06a855fe7 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -28,7 +28,7 @@ jobs: - pwsh: | git branch -vv - $diff = git diff internal/sync-fabricbot-json^ internal/sync-fabricbot-json + $diff = git diff internal/sync-fabricbot-json^..internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 39903d87f7b02bc6db6638a5c890ca600304fcdd Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 13:33:37 +0800 Subject: [PATCH 71/84] testt --- .azure-pipelines/sync-aliases.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index e4a06a855fe7..f4aeea3ce7ab 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -10,6 +10,7 @@ jobs: - job: UpdateJson displayName: Update fabricbot.json steps: + - checkout: self - pwsh: | ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally @@ -28,7 +29,7 @@ jobs: - pwsh: | git branch -vv - $diff = git diff internal/sync-fabricbot-json^..internal/sync-fabricbot-json + $diff = git diff main internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From d7625c76daf5bfee9affb36a126b155a045a9282 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 13:37:07 +0800 Subject: [PATCH 72/84] testt --- .azure-pipelines/sync-aliases.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index f4aeea3ce7ab..04d9ef6f65df 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -10,7 +10,9 @@ jobs: - job: UpdateJson displayName: Update fabricbot.json steps: - - checkout: self + - checkout: + self: + ref: main - pwsh: | ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally From fdcbe43e73b5f63cef15f8a41fac6e0b38e53c8e Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 13:39:31 +0800 Subject: [PATCH 73/84] testt --- .azure-pipelines/sync-aliases.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 04d9ef6f65df..41d4bafcaca5 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -11,8 +11,8 @@ jobs: displayName: Update fabricbot.json steps: - checkout: - self: - ref: main + self: + ref: main - pwsh: | ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally From 02753b610f75174681e4feecb665dce01e693fab Mon Sep 17 00:00:00 2001 From: xtR0d666 <69706194+xtR0d666@users.noreply.github.com> Date: Wed, 15 Feb 2023 13:42:31 +0800 Subject: [PATCH 74/84] Update sync-aliases.yml for Azure Pipelines --- .azure-pipelines/sync-aliases.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 41d4bafcaca5..5ca6e88dbae8 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -10,14 +10,13 @@ jobs: - job: UpdateJson displayName: Update fabricbot.json steps: - - checkout: - self: - ref: main + - checkout: self - pwsh: | ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally - pwsh: | + git branch -vv git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" git checkout -b "internal/sync-fabricbot-json" From 61c276f8f831f890a05359174c09566f09587246 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 14:28:43 +0800 Subject: [PATCH 75/84] testt --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 41d4bafcaca5..8bfe19dff625 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -31,7 +31,7 @@ jobs: - pwsh: | git branch -vv - $diff = git diff main internal/sync-fabricbot-json + $diff = git diff (internal/sync-fabricbot-json)^ internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 158c6c2f1e10e2c843a87ead592e09a2a84e1500 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 14:32:58 +0800 Subject: [PATCH 76/84] testt --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index a4e375a4deb6..207dabee6e4c 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -30,7 +30,7 @@ jobs: - pwsh: | git branch -vv - $diff = git diff (internal/sync-fabricbot-json)^ internal/sync-fabricbot-json + $diff = git diff internal/sync-fabricbot-json^ internal/sync-fabricbot-json if ($diff.Length -eq 0) { Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." } else { From 57e2409d63a70885b8a3b133e242bd3b671ed5ee Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 17:27:35 +0800 Subject: [PATCH 77/84] test yml condition synthx --- .azure-pipelines/sync-aliases.yml | 32 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 207dabee6e4c..8defc8321a46 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -15,6 +15,17 @@ jobs: ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally + - pwsh: | + $gitStatus = git status -s + if ($gitStatus -eq "") { + Write-Host "The wiki has no changes ." + Write-Host "##vso[task.setvariable variable=ChangesDetected]false" + } else { + Write-Host "There are changes in the repository." + Write-Host "##vso[task.setvariable variable=ChangesDetected]true" + } + displayName: Check if Wiki table has any changes + - pwsh: | git branch -vv git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" @@ -27,20 +38,13 @@ jobs: git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force displayName: Git commit and push + condition: and(eq(variables['ChangesDetected'], 'true')) - pwsh: | - git branch -vv - $diff = git diff internal/sync-fabricbot-json^ internal/sync-fabricbot-json - if ($diff.Length -eq 0) { - Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." - } else { - Write-Host "you differences" - exit 0; - $Title = "Sync fabricbot.json According To ADO Wiki Page" - $HeadBranch = "internal/sync-fabricbot-json" - $BaseBranch = "main" - $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" - ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description - } + $Title = "Sync fabricbot.json According To ADO Wiki Page" + $HeadBranch = "internal/sync-fabricbot-json" + $BaseBranch = "main" + $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" + ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description displayName: Create PR to main branch - + condition: and(eq(variables['ChangesDetected'], 'true')) \ No newline at end of file From 3bbaaa500b8a2219a94eca6e885cfe256e9591b0 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 17:29:26 +0800 Subject: [PATCH 78/84] add succeed --- .azure-pipelines/sync-aliases.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 8defc8321a46..f4c838078cea 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -38,7 +38,7 @@ jobs: git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; git push origin internal/sync-fabricbot-json --force displayName: Git commit and push - condition: and(eq(variables['ChangesDetected'], 'true')) + condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) - pwsh: | $Title = "Sync fabricbot.json According To ADO Wiki Page" @@ -47,4 +47,4 @@ jobs: $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description displayName: Create PR to main branch - condition: and(eq(variables['ChangesDetected'], 'true')) \ No newline at end of file + condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) \ No newline at end of file From 9b3371f40632818bf1f1730e638afd0a6a0205e3 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 17:34:24 +0800 Subject: [PATCH 79/84] add trim --- .azure-pipelines/sync-aliases.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index f4c838078cea..13b43e2b9ceb 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -17,7 +17,7 @@ jobs: - pwsh: | $gitStatus = git status -s - if ($gitStatus -eq "") { + if ($gitStatus.Trim() -eq "") { Write-Host "The wiki has no changes ." Write-Host "##vso[task.setvariable variable=ChangesDetected]false" } else { @@ -27,7 +27,6 @@ jobs: displayName: Check if Wiki table has any changes - pwsh: | - git branch -vv git config --global user.email "65331932+azure-powershell-bot@users.noreply.github.com" git config --global user.name "azure-powershell-bot" git checkout -b "internal/sync-fabricbot-json" From dee9ddfe8c6242a8d8e05510ad216c8cdfa0d142 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 17:43:22 +0800 Subject: [PATCH 80/84] add null check --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 13b43e2b9ceb..c2929f1614dd 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -17,7 +17,7 @@ jobs: - pwsh: | $gitStatus = git status -s - if ($gitStatus.Trim() -eq "") { + if (-not $gitStatus) { Write-Host "The wiki has no changes ." Write-Host "##vso[task.setvariable variable=ChangesDetected]false" } else { From 89e7f90d0b917678110ceeb172c2153fe6016fce Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 17:51:55 +0800 Subject: [PATCH 81/84] add newline --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index c2929f1614dd..1fe9b597fc55 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -46,4 +46,4 @@ jobs: $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description displayName: Create PR to main branch - condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) \ No newline at end of file + condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) From 20c915ec19e9cdaddb209b6e7d54c56238d85948 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 17:53:00 +0800 Subject: [PATCH 82/84] remove checkout --- .azure-pipelines/sync-aliases.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 1fe9b597fc55..50a176d266a8 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -10,7 +10,6 @@ jobs: - job: UpdateJson displayName: Update fabricbot.json steps: - - checkout: self - pwsh: | ./tools/Github/ParseWiki2Json.ps1 -ADOToken $(ADOToken) displayName: Update fabricbot.json file locally From aab95156016fe0c79b513bfef520ad74c8ea5ebb Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Wed, 15 Feb 2023 17:54:05 +0800 Subject: [PATCH 83/84] use right url --- .azure-pipelines/sync-aliases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 0f4f5f1c777b..0f84017e3e9c 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -33,7 +33,7 @@ jobs: git add . git commit -m "Sync fabricbot.json" - git remote set-url origin https://$(BotAccessToken)@github.com/xtr0d666/azure-powershell.git; + git remote set-url origin https://azure-powershell-bot:$(BotAccessToken)@github.com/Azure/azure-powershell.git; git push origin internal/sync-fabricbot-json --force displayName: Git commit and push condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) From 8398c6ccc619b834c00b4af71c5a210b67471491 Mon Sep 17 00:00:00 2001 From: "Hongtu Zhang (FA Talent)" Date: Thu, 16 Feb 2023 00:18:32 +0800 Subject: [PATCH 84/84] remove diff --- .azure-pipelines/sync-aliases.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.azure-pipelines/sync-aliases.yml b/.azure-pipelines/sync-aliases.yml index 0f84017e3e9c..1a1e4d226524 100644 --- a/.azure-pipelines/sync-aliases.yml +++ b/.azure-pipelines/sync-aliases.yml @@ -39,15 +39,10 @@ jobs: condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) - pwsh: | - $diff = git diff main..internal/sync-fabricbot-json - if ($diff.Length -eq 0) { - Write-Host "No differences between main and internal/sync-fabricbot-json. Skipping PR creation." - } else { - $Title = "Sync fabricbot.json According To ADO Wiki Page" - $HeadBranch = "internal/sync-fabricbot-json" - $BaseBranch = "main" - $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" - ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description - } + $Title = "Sync fabricbot.json According To ADO Wiki Page" + $HeadBranch = "internal/sync-fabricbot-json" + $BaseBranch = "main" + $Description = "This PR sync taskType: scheduledAndTrigger part of fabricbot.json from table of Service-Team-Label-and-Contact-List in ADO wiki page" + ./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description displayName: Create PR to main branch condition: and(succeeded(), eq(variables['ChangesDetected'], 'true'))