-
Notifications
You must be signed in to change notification settings - Fork 4k
add pipeline yml for syncing fabricbot.json aliases #20772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wyunchi-ms
merged 53 commits into
Azure:main
from
greathongtu:pipeline_for_fabricbot_aliases
Feb 9, 2023
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
2e9c6d2
add pipeline yml for syncing fabricbot.json aliases
f77bd21
change git user name and email in script
38b1f70
change inline script to GetUncyclo2Json.ps1 file
2e5c08a
remove unnecessary code
80aa187
change wrong dir
2831172
change to my personal repo for test
74313ff
change the usage of token
d25175c
change CreatePR.ps1 for test
c91b484
correct ParseUncyclo2Json.ps1
59a49c5
remove unnecessary output
d5e453e
remove quote
cf4bc10
finish test, change back to Azure repo
17b5be6
change branch name
11eccd6
change some names
bb4d892
remove the use of magic number
5b248b3
change commit message
91438f7
remove redundant git pull
dc0e489
change the way of getting wiki content
b5e6f7e
change space to -
0d2bbff
add md
affdb10
set current dir
ab482d1
use space
59d5cd6
use -
5d90c4b
still use ADOToken
635afa3
use a better wiki url
bcec48e
test purpose
0eef6bb
test2
fabc2b9
test oauth
60c55cb
test3
d796b9d
finish test
fdf250c
test again
198f2b0
test
51fffc1
finish test
ed35c0e
test cron
0f4ae7c
test double pr
b1924f2
solve double pr
d323d0d
test
d5ac369
test
e663991
test
95ff796
finish test
2d350cb
test
9bc5aab
finish test
2c5648d
test restapi
e829d30
te
e603ebb
finish test
878e781
test
077a711
finish test
9681afb
filter pr
40f8997
test
1b3634a
test
734537a
test
72f6684
test
1c4b9f3
finish test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Variable 'ADOToken' and 'BotAccessToken' was defined in the Variables tab | ||
schedules: | ||
- cron: "50 15 * * *" | ||
displayName: 11:50 PM (UTC + 8:00) China Daily Run | ||
branches: | ||
include: | ||
- main | ||
|
||
jobs: | ||
- job: UpdateJson | ||
displayName: Update fabricbot.json | ||
steps: | ||
- pwsh: | | ||
./tools/Github/ParseUncyclo2Json.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 "[email protected]" | ||
git config --global user.name "azure-powershell-bot" | ||
git checkout -b "internal/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 | ||
|
||
- pwsh: | | ||
$Title = "Sync fabricbot.json According To ADO Uncyclo 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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# | ||
# 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]$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?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) { | ||
$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 | ||
$WholeJson = Get-Content -Raw -Path .github/fabricbot.json | ConvertFrom-Json | ||
|
||
$WholeJson.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() | ||
} | ||
} | ||
|
||
($WholeJson | ConvertTo-Json -Depth 32) | Out-File -FilePath .github/fabricbot.json |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.