forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
{CI} Sync resourceManagement.yml according To ADO Wiki Page - Service…
… Contact List (Azure#8288) * {CI} Sync resourceManagement.yml alias pipeline * create pr against main branch * Sync resourceManagement.yml --------- Co-authored-by: Qi Pan <[email protected]>
- Loading branch information
Showing
3 changed files
with
717 additions
and
98 deletions.
There are no files selected for viewing
This file contains 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,92 @@ | ||
name: Azure CLI Sync Alias | ||
|
||
schedules: | ||
- cron: "50 15 * * 0" | ||
displayName: 11:50 PM (UTC + 8:00) China Weekly Run | ||
branches: | ||
include: | ||
- main | ||
|
||
# The 'resources' and 'uses' below are used to resolve the error 'Repository associated with wiki ID <WikiId> does not exist or you do not have permissions for the operation you are attempting.' | ||
resources: | ||
repositories: | ||
- repository: ServiceContactList | ||
type: git | ||
name: internal.wiki | ||
|
||
jobs: | ||
- job: UpdateYaml | ||
displayName: Update resourceManagement.yml | ||
pool: pool-windows-2019 | ||
uses: | ||
repositories: | ||
- ServiceContactList | ||
|
||
steps: | ||
- task: UseDotNet@2 | ||
displayName: Install .NET 8 SDK | ||
inputs: | ||
packageType: sdk | ||
version: 8.0.x | ||
|
||
- pwsh: | | ||
dotnet --version | ||
dotnet new tool-manifest --force | ||
dotnet tool install powershell --version 7.4.* | ||
displayName: Install PowerShell 7.4.x | ||
- pwsh: | | ||
dotnet tool run pwsh -NoLogo -NoProfile -NonInteractive -File ./scripts/automation/ParseServiceContactsList.ps1 -AccessToken $env:SYSTEM_ACCESSTOKEN | ||
env: | ||
SYSTEM_ACCESSTOKEN: $(System.AccessToken) | ||
displayName: Update resourceManagement.yml file locally | ||
- pwsh: | | ||
$hasChanges = git diff --name-only .github/policies | ||
if ($null -eq $hasChanges) { | ||
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 | ||
- task: AzurePowerShell@5 | ||
inputs: | ||
pwsh: true | ||
azureSubscription: '$(AZURE_SDK_INFRA_SUB_CONNECTED_SERVICE)' | ||
ScriptType: 'InlineScript' | ||
Inline: | | ||
$GithubToken = Get-AzKeyVaultSecret -VaultName $(GithubPATKeyVaultName) -Name $(GithubPATKeyVaultAccount) -AsPlainText | ||
Write-Host "##vso[task.setvariable variable=GithubToken;issecret=true]$GithubToken" | ||
azurePowerShellVersion: 'LatestVersion' | ||
displayName: Get Github PAT from Key Vault | ||
|
||
- pwsh: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Azure CLI Team" | ||
git checkout -b "sync_alias_$env:Build_BuildId" | ||
git add .github/policies | ||
git commit -m "Sync resourceManagement.yml" | ||
git remote set-url origin https://azclibot:$(GithubToken)@github.com/Azure/azure-cli-extensions.git; | ||
git push origin "sync_alias_$env:Build_BuildId" --force | ||
displayName: Git commit and push | ||
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) | ||
- pwsh: | | ||
$Title = "{CI} Sync resourceManagement.yml according To ADO Wiki Page - Service Contact List" | ||
$HeadBranch = "sync_alias_$env:Build_BuildId" | ||
$BaseBranch = "main" | ||
$Description = "This PR synchronizes the task: 'Triage issues to the service team' part of resourceManagement.yml from table of Service Contact List in ADO wiki page" | ||
$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $(GithubToken)" } | ||
$RequestBody = @{"title" = $Title; "body" = $Description; "head" = $HeadBranch; "base" = $BaseBranch;} | ||
$Uri = "https://api.github.com/repos/Azure/azure-cli-extensions/pulls" | ||
Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json) | ||
displayName: Create PR to main branch | ||
condition: and(succeeded(), eq(variables['ChangesDetected'], 'true')) |
Oops, something went wrong.