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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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/53] 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)