Skip to content

Commit

Permalink
Create PR in OneLocBuild task only on third week of sprint (#755)
Browse files Browse the repository at this point in the history
* Fix localization pipeline

* Add missed change

* Added option to disable PR creation
  • Loading branch information
EzzhevNikita authored Apr 21, 2021
1 parent abd544d commit e10292e
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Localize/localize-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ stages:

- powershell: |
$sprintInfo = Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept"= "application/json"} | ConvertFrom-Json
Write-Host "##vso[task.setvariable variable=week]$($sprintInfo.week)"
Write-Host "##vso[task.setvariable variable=sprint]$($sprintInfo.sprint)"
if (($env:PR_CREATION_ENABLED -eq 'True') -and (($sprintInfo.week -eq 3) -or ($env:BUILD_REASON -eq 'Manual')))
{
Write-Host "shouldCreatePR was set to true"
Write-Host "##vso[task.setvariable variable=shouldCreatePR]$($true)"
}
else
{
Write-Host "shouldCreatePR was set to false"
Write-Host "##vso[task.setvariable variable=shouldCreatePR]$($false)"
}
displayName: "Determine the number of the week in the sprint and sprint number"
- powershell: |
Expand All @@ -34,26 +42,26 @@ stages:
git merge origin/master
git push origin Localization
displayName: "Sync with master branch"
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
condition: and(succeeded(), in(variables['build.reason'], 'Schedule', 'Manual'))
- task: OneLocBuild@2
inputs:
locProj: 'Localize/LocProject.json'
outDir: '$(Build.ArtifactStagingDirectory)'
packageSourceAuth: 'patAuth'
patVariable: '$(OneLocBuildPAT)'
isCreatePrSelected: true
isCreatePrSelected: $(shouldCreatePR)
repoType: 'gitHub'
prSourceBranchPrefix: 'Localize'
gitHubPatVariable: '$(GitHubPAT)'
isAutoCompletePrSelected: true
gitHubPrMergeMethod: 'squash'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
condition: and(succeeded(), in(variables['build.reason'], 'Schedule', 'Manual'))

- task: PublishBuildArtifacts@1
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
condition: and(succeeded(), in(variables['build.reason'], 'Schedule', 'Manual'))
displayName: 'Publish an artifact'

- powershell: |
Expand All @@ -69,7 +77,7 @@ stages:
git commit -m "Removing Localize folder"
git push origin $updateBranch
displayName: Create and push localization update branch
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
condition: and(succeeded(), or(and(eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
- task: PowerShell@2
inputs:
Expand All @@ -79,7 +87,7 @@ stages:
env:
GH_TOKEN: '$(GitHubPAT)'
displayName: Open a PR
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
condition: and(succeeded(), or(and(eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))

- powershell: |
$message="Created task-lib localization update PR. Someone please approve/merge it. :please-puss-in-boots: $env:PR_LINK"
Expand All @@ -89,7 +97,7 @@ stages:
Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
displayName: 'Send Slack notification about PR opened'
condition: and(succeeded(), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
condition: and(succeeded(), eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule'))
- powershell: |
$buildUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&_a=summary"
Expand All @@ -100,4 +108,4 @@ stages:
Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
displayName: 'Send Slack notification about error'
condition: and(failed(), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
condition: and(failed(), eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule'))

0 comments on commit e10292e

Please sign in to comment.