@@ -2,13 +2,40 @@ name: $(Date:MMddyy)$(Rev:.rrrr)
22
33trigger : none
44
5+ schedules :
6+ - cron : 0 8 * * Mon # mm HH DD MM DW
7+ displayName : Localization update
8+ branches :
9+ include :
10+ - Localization
11+ always : true
12+
513stages :
614- stage : __default
715 jobs :
8- - job : Job1
16+ - job : LocalizationUpdate
17+ displayName : ' Update localization'
918 pool :
1019 vmImage : windows-latest
1120 steps :
21+ - checkout : self
22+ persistCredentials : true
23+
24+ - powershell : |
25+ $sprintInfo = Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept"= "application/json"} | ConvertFrom-Json
26+ Write-Host "##vso[task.setvariable variable=week]$($sprintInfo.week)"
27+ Write-Host "##vso[task.setvariable variable=sprint]$($sprintInfo.sprint)"
28+ displayName: "Determine the number of the week in the sprint and sprint number"
29+
30+ - powershell : |
31+ git config --global user.email "$(github_email)"
32+ git config --global user.name "$(username)"
33+ git checkout -b Localization origin/Localization
34+ git merge origin/master
35+ git push origin Localization
36+ displayName: "Sync with master branch"
37+ condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
38+
1239 - task : OneLocBuild@2
1340 inputs :
1441 locProj : ' Localize/LocProject.json'
@@ -19,10 +46,55 @@ stages:
1946 repoType : ' gitHub'
2047 prSourceBranchPrefix : ' Localize'
2148 gitHubPatVariable : ' $(GitHubPAT)'
22- isAutoCompletePrSelected : false
49+ isAutoCompletePrSelected : true
50+ gitHubPrMergeMethod : ' squash'
2351 env :
2452 SYSTEM_ACCESSTOKEN : $(System.AccessToken)
53+ condition : and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
54+
55+ - powershell : |
56+ $date= Get-Date -Format "MMddyyyy"
57+ $updateBranch="Localization-update_$date"
58+ echo "##vso[task.setvariable variable=updateBranch]$updateBranch"
59+
60+ git checkout -b $updateBranch
61+
62+ Remove-Item -Recurse -Force Localize
63+
64+ git add -A
65+ git commit -m "Removing Localize folder"
66+ git push origin $updateBranch
67+ displayName: Create and push localization update branch
68+ condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
69+
70+ - task : PowerShell@2
71+ inputs :
72+ filePath : ' open-pullrequest.ps1'
73+ arguments : " -SourceBranch $(updateBranch)"
74+ failOnStderr : true
75+ env :
76+ GH_TOKEN : ' $(GitHubPAT)'
77+ displayName : Open a PR
78+ condition : and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
79+
80+ - powershell : |
81+ $message="Created task-lib localization update PR. Someone please approve/merge it. :please-puss-in-boots: $env:PR_LINK"
82+ $body = [PSCustomObject]@{
83+ text = $message
84+ } | ConvertTo-Json
85+
86+ Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
87+ displayName: 'Send Slack notification about PR opened'
88+ condition: and(succeeded(), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
89+
90+ - powershell : |
91+ $buildUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&_a=summary"
92+ $message="Something went wrong while creating task-lib localization update PR. Build: $buildUrl"
93+ $body = [PSCustomObject]@{
94+ text = $message
95+ } | ConvertTo-Json
2596
26- - task : PublishBuildArtifacts@1
27- displayName : ' Publish Artifact: drop'
97+ Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
98+ displayName: 'Send Slack notification about error'
99+ condition: and(failed(), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
28100
0 commit comments