Skip to content
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

Create PR in OneLocBuild task only on third week of sprint #14758

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions Localize/localize-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ stages:

- powershell: |
$sprintInfo = Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept"= "application/json"} | ConvertFrom-Json
Write-Host "##vso[task.setvariable variable=week]$($sprintInfo.week)"
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)"
}
Write-Host "##vso[task.setvariable variable=sprint]$($sprintInfo.sprint)"
EzzhevNikita marked this conversation as resolved.
Show resolved Hide resolved
displayName: "Determine the number of the week in the sprint and sprint number"

Expand All @@ -39,16 +48,16 @@ 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
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'))
EzzhevNikita marked this conversation as resolved.
Show resolved Hide resolved
inputs:
locProj: 'Localize/LocProject.json'
outDir: '$(Build.ArtifactStagingDirectory)'
packageSourceAuth: 'patAuth'
patVariable: '$(OneLocBuildPAT)'
isCreatePrSelected: false
isCreatePrSelected: $(shouldCreatePR)
repoType: 'gitHub'
prSourceBranchPrefix: 'Localize'
gitHubPatVariable: '$(GitHubPAT)'
Expand All @@ -58,7 +67,7 @@ stages:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

- 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 @@ -67,7 +76,7 @@ stages:
git add -A
git commit -m 'Bumped versions'
displayName: Bump tasks' and packages' versions
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: |
$date= Get-Date -Format "MMddyyyy"
Expand All @@ -82,7 +91,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 @@ -92,7 +101,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 tasks localization update PR. Someone please approve/merge it. :please-puss-in-boots: $env:PR_LINK"
Expand All @@ -101,7 +110,7 @@ stages:
} | ConvertTo-Json
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 @@ -111,4 +120,4 @@ stages:
} | ConvertTo-Json
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'))