Skip to content

Commit

Permalink
Merge pull request #120 from microsoft/users/anatolybolshakov/Localiz…
Browse files Browse the repository at this point in the history
…ation-fix

Localization branch - returned back localize-pipeline.yml and LocProject.json files
  • Loading branch information
Anatoly Bolshakov authored Jun 17, 2021
2 parents b33a67f + f608a53 commit 38059bb
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Localize/LocProject.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Projects": [
{
"LocItems": [
{
"Languages": "de-DE;es-ES;fr-FR;it-IT;ja-JP;ko-KR;ru-RU;zh-CN;zh-TW",
"SourceFile": "Strings\\resources.resjson\\en-US\\resources.resjson",
"CopyOption": "LangIDOnPath",
"OutputPath": "Strings\\resources.resjson"
}
]
}
]
}
102 changes: 102 additions & 0 deletions Localize/localize-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
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: LocalizationUpdate
pool:
vmImage: windows-latest
steps:

- checkout: self
persistCredentials: true

- powershell: |
$sprintInfo = Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept"= "application/json"} | ConvertFrom-Json
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: |
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(), in(variables['build.reason'], 'Schedule', 'Manual'))
- task: OneLocBuild@2
condition: and(succeeded(), in(variables['build.reason'], 'Schedule', 'Manual'))
inputs:
locProj: 'Localize/LocProject.json'
outDir: '$(Build.ArtifactStagingDirectory)'
packageSourceAuth: 'patAuth'
patVariable: '$(OneLocBuildPAT)'
isCreatePrSelected: $(shouldCreatePR)
repoType: 'gitHub'
prSourceBranchPrefix: 'Localize'
gitHubPatVariable: '$(GitHubPAT)'
isAutoCompletePrSelected: true
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

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

- 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['SHOULDCREATEPR'], 'True'), 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['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))

- powershell: |
$message="Created tool-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['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule'))
- powershell: |
$buildUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&_a=summary"
$message="Something went wrong while creating tool-lib localization update PR. Build: $buildUrl"
$body = [PSCustomObject]@{
text = $message
} | ConvertTo-Json
Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
displayName: 'Send Slack notification about error'
condition: and(failed(), eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule'))

0 comments on commit 38059bb

Please sign in to comment.