|
| 1 | +name: Download localization strings |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Loc handback is every Mon/Thu. |
| 6 | + # We are running on every Tue/Fri 08:00 UTC, which is Tue/Fri 00:00 PST or 01:00 PST DST. |
| 7 | + - cron: '0 8 * * 2,5' |
| 8 | + workflow_dispatch: {} |
| 9 | + |
| 10 | +jobs: |
| 11 | + download: |
| 12 | + environment: localization-database |
| 13 | + name: Download |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/git/items/get?view=azure-devops-rest-7.1&tabs=HTTP |
| 18 | + - run: | |
| 19 | + mkdir localization-files/ |
| 20 | +
|
| 21 | + for locale in ar-SA bg-BG ca-ES cs-CZ da-DK de-DE el-GR es-ES et-EE eu-ES fi-FI fr-FR gl-ES he-IL hi-IN hr-HR hu-HU id-ID it-IT ja-JP kk-KZ ko-KR lt-LT lv-LV ms-MY nb-NO nl-NL pl-PL pt-BR pt-PT ro-RO ru-RU sk-SK sl-SI sr-Cyrl-CS sr-Latn-CS sv-SE th-TH tr-TR uk-UA vi-VN zh-CN zh-HK zh-TW |
| 22 | + do |
| 23 | + echo Downloading localization strings for "$locale". |
| 24 | + curl --fail --output localization-files/$locale.json --user ${{ secrets.ADO_USERNAME }}:${{ secrets.ADO_TOKEN }} https://dev.azure.com/bagie/Production/_apis/git/repositories/D365_CE/items?api-version=7.0\&download=true\&path=/Feature/CustomerCare_Apps/UI/$locale/BotFramework-WebChat/packages/api/src/Localization/$locale.json |
| 25 | + done |
| 26 | +
|
| 27 | + - uses: actions/upload-artifact@v3 |
| 28 | + with: |
| 29 | + name: localization-files |
| 30 | + path: localization-files/ |
| 31 | + |
| 32 | + create-pull-request: |
| 33 | + environment: localization-database |
| 34 | + name: Create pull request for new changes |
| 35 | + needs: |
| 36 | + - download |
| 37 | + permissions: |
| 38 | + contents: write |
| 39 | + runs-on: ubuntu-latest |
| 40 | + |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v3.3.0 |
| 43 | + |
| 44 | + - uses: actions/download-artifact@v3 |
| 45 | + with: |
| 46 | + name: localization-files |
| 47 | + path: packages/api/src/localization |
| 48 | + |
| 49 | + - id: checks |
| 50 | + name: Check if contains new changes |
| 51 | + run: | |
| 52 | + if [ ! -z "$(git status --porcelain)" ]; |
| 53 | + then |
| 54 | + echo has-changes=1 >> $GITHUB_OUTPUT |
| 55 | + echo branch-name=loc-`date +"%Y%m%d-%H%M%S"` >> $GITHUB_OUTPUT |
| 56 | + else |
| 57 | + echo No new changes. >> $GITHUB_STEP_SUMMARY |
| 58 | + fi |
| 59 | +
|
| 60 | + - if: ${{ steps.checks.outputs.has-changes }} |
| 61 | + name: Create branch |
| 62 | + run: | |
| 63 | + git config user.name 'github-actions[bot]' |
| 64 | + git config user.email 'github-actions[bot]@users.noreply.github.com' |
| 65 | + git checkout -b ${{ steps.checks.outputs.branch-name }} |
| 66 | + git add . |
| 67 | + git commit --message="Localization sync" |
| 68 | + git push --set-upstream origin HEAD |
| 69 | +
|
| 70 | + - env: |
| 71 | + GH_TOKEN: ${{ secrets.GH_TOKEN_FOR_PULL_REQUEST }} |
| 72 | + if: ${{ steps.checks.outputs.has-changes }} |
| 73 | + name: Create pull request |
| 74 | + run: | |
| 75 | + PULL_REQUEST_NUMBER=`gh api repos/${{ github.repository }}/pulls --field base=${{ github.ref }} --field head=${{ steps.checks.outputs.branch-name }} --field title="Localization sync" | jq -r '.number'` |
| 76 | + gh api repos/${{ github.repository }}/issues/$PULL_REQUEST_NUMBER/assignees --field assignees[]=compulim |
| 77 | + gh api repos/${{ github.repository }}/issues/$PULL_REQUEST_NUMBER/labels --field labels[]=area-localization --field labels[]=bot |
| 78 | + echo Pull request created at https://github.com/${{ github.repository }}/pull/$PULL_REQUEST_NUMBER. >> $GITHUB_STEP_SUMMARY |
0 commit comments