@@ -17,10 +17,23 @@ stages:
1717 pool :
1818 vmImage : windows-latest
1919 steps :
20+ - checkout : self
21+ persistCredentials : true
22+
2023 - powershell : |
21- $week = (Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept"= "application/json"} | ConvertFrom-Json).week
22- Write-Host "##vso[task.setvariable variable=week]$week"
23- displayName: "Determine the number of the week in the sprint"
24+ $sprintInfo = Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept"= "application/json"} | ConvertFrom-Json
25+ Write-Host "##vso[task.setvariable variable=week]$($sprintInfo.week)"
26+ Write-Host "##vso[task.setvariable variable=sprint]$($sprintInfo.sprint)"
27+ displayName: "Determine the number of the week in the sprint and sprint number"
28+
29+ - powershell : |
30+ git config --global user.email "$(github_email)"
31+ git config --global user.name "$(username)"
32+ git checkout -b Localization origin/Localization
33+ git merge origin/master
34+ git push origin Localization
35+ displayName: "Sync with master branch"
36+ condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
2437
2538 - task : OneLocBuild@2
2639 inputs :
@@ -32,23 +45,54 @@ stages:
3245 repoType : ' gitHub'
3346 prSourceBranchPrefix : ' Localize'
3447 gitHubPatVariable : ' $(GitHubPAT)'
35- isAutoCompletePrSelected : false
48+ isAutoCompletePrSelected : true
3649 env :
3750 SYSTEM_ACCESSTOKEN : $(System.AccessToken)
51+ condition : and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
52+
53+ - powershell : |
54+ $date= Get-Date -Format "MMddyyyy"
55+ $updateBranch="Localization-update_$date"
56+ echo "##vso[task.setvariable variable=updateBranch]$updateBranch"
57+
58+ git checkout -b $updateBranch
59+
60+ Remove-Item -Recurse -Force Localize
61+
62+ git add -A
63+ git commit -m "Removing Localize folder"
64+ git push origin $updateBranch
65+ displayName: Create and push localization update branch
66+ condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
67+
68+ - task : PowerShell@2
69+ inputs :
70+ filePath : ' open-pullrequest.ps1'
71+ arguments : " -SourceBranch $(updateBranch)"
72+ failOnStderr : true
73+ env :
74+ GH_TOKEN : ' $(GitHubPAT)'
75+ displayName : Open a PR
76+ condition : and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
3877
3978 - powershell : |
40- $body = '{"text": "Created task-lib localization update PR. Someone please approve/merge it. :please-puss-in-boots:"}'
79+ $message="Created task-lib localization update PR. Someone please approve/merge it. :please-puss-in-boots: $env:PR_LINK"
80+ $body = [PSCustomObject]@{
81+ text = $message
82+ } | ConvertTo-Json
83+
4184 Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
4285 displayName: 'Send Slack notification about PR opened'
43- condition: and(succeeded (), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
86+ condition: and(failed (), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
4487
4588 - powershell : |
4689 $buildUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&_a=summary"
47- $body = '{"text": "Something went wrong while creating task-lib localization update PR. Build: ' + $buildUrl + '"}'
90+ $message="Something went wrong while creating task-lib localization update PR. Build: $buildUrl"
91+ $body = [PSCustomObject]@{
92+ text = $message
93+ } | ConvertTo-Json
94+
4895 Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
4996 displayName: 'Send Slack notification about error'
5097 condition: and(failed(), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
5198
52- - task : PublishBuildArtifacts@1
53- displayName : ' Publish Artifact: drop'
54-
0 commit comments