Skip to content

Commit

Permalink
Applied enhancements for the localization pipeline (#733)
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
egor-bryzgalov committed Mar 12, 2021
1 parent b5221d3 commit ecc61e0
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 5 deletions.
80 changes: 76 additions & 4 deletions Localize/localize-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,40 @@ name: $(Date:MMddyy)$(Rev:.rrrr)

trigger: none

schedules:
- cron: 0 8 * * Mon # mm HH DD MM DW
displayName: Localization update
branches:
include:
- Localization
always: true

stages:
- stage: __default
jobs:
- job: Job1
- job: LocalizationUpdate
displayName: 'Update localization'
pool:
vmImage: windows-latest
steps:
- checkout: self
persistCredentials: true

- 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)"
displayName: "Determine the number of the week in the sprint and sprint number"
- powershell: |
git config --global user.email "$(github_email)"
git config --global user.name "$(username)"
git checkout -b Localization origin/Localization
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')))
- task: OneLocBuild@2
inputs:
locProj: 'Localize/LocProject.json'
Expand All @@ -19,10 +46,55 @@ stages:
repoType: 'gitHub'
prSourceBranchPrefix: 'Localize'
gitHubPatVariable: '$(GitHubPAT)'
isAutoCompletePrSelected: false
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')))

- powershell: |
$date= Get-Date -Format "MMddyyyy"
$updateBranch="Localization-update_$date"
echo "##vso[task.setvariable variable=updateBranch]$updateBranch"
git checkout -b $updateBranch
Remove-Item -Recurse -Force Localize
git add -A
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')))
- task: PowerShell@2
inputs:
filePath: 'open-pullrequest.ps1'
arguments: "-SourceBranch $(updateBranch)"
failOnStderr: true
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')))

- powershell: |
$message="Created task-lib localization update PR. Someone please approve/merge it. :please-puss-in-boots: $env:PR_LINK"
$body = [PSCustomObject]@{
text = $message
} | 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'))
- powershell: |
$buildUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&_a=summary"
$message="Something went wrong while creating task-lib localization update PR. Build: $buildUrl"
$body = [PSCustomObject]@{
text = $message
} | ConvertTo-Json
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
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'))
3 changes: 2 additions & 1 deletion open-pullrequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ $body = "This PR was auto-generated with [the localization pipeline build]($buil
gh pr create --head $SourceBranch --title 'Localization update' --body $body

# Getting a link to the opened PR
$env:PR_LINK = Get-PullRequest
$PR_LINK = Get-PullRequest
Write-Host "##vso[task.setvariable variable=PR_LINK]$PR_LINK"

0 comments on commit ecc61e0

Please sign in to comment.