Skip to content

Commit

Permalink
Merge pull request #4866 from newrelic/2539_MT_workflows
Browse files Browse the repository at this point in the history
add, update workflows for machine translation
  • Loading branch information
zstix committed Nov 15, 2021
2 parents 915e8b8 + ff301b5 commit 82c7feb
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/add-slugs-to-translate-queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

env:
DB_CONNECTION_INFO: ${{ secrets.DB_CONNECTION_INFO }}
HUMAN_TRANSLATION_PROJECT_ID: ${{ secrets.HUMAN_TRANSLATION_PROJECT_ID }}
MACHINE_TRANSLATION_PROJECT_ID: ${{ secrets.MACHINE_TRANSLATION_PROJECT_ID }}

jobs:
get-and-save-slugs:
Expand Down
89 changes: 86 additions & 3 deletions .github/workflows/check-translations-and-deserialize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:

env:
TRANSLATION_VENDOR_API_URL: ${{ secrets.TRANSLATION_VENDOR_API_URL }}
TRANSLATION_VENDOR_PROJECT: ${{ secrets.TRANSLATION_VENDOR_PROJECT }}
TRANSLATION_VENDOR_USER: ${{ secrets.TRANSLATION_VENDOR_USER }}
TRANSLATION_VENDOR_SECRET: ${{ secrets.TRANSLATION_VENDOR_SECRET }}
DB_CONNECTION_INFO: ${{ secrets.DB_CONNECTION_INFO }}
BOT_NAME: nr-opensource-bot
BOT_EMAIL: opensource+bot@newrelic.com
Expand All @@ -20,6 +17,10 @@ jobs:
fetch-content:
name: Fetch translated content
runs-on: ubuntu-latest
env:
TRANSLATION_VENDOR_PROJECT: ${{ secrets.TRANSLATION_VENDOR_PROJECT }}
TRANSLATION_VENDOR_USER: ${{ secrets.TRANSLATION_VENDOR_USER }}
TRANSLATION_VENDOR_SECRET: ${{ secrets.TRANSLATION_VENDOR_SECRET }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -69,6 +70,88 @@ jobs:
branch-suffix: short-commit-hash
base: develop
delete-branch: true
team-reviewers: developer-enablement

- name: Checkout repository
if: steps.fetch-deserialize.outputs.batchesToDeserialize != 0
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Remove Completed Batches From Queue
if: steps.fetch-deserialize.outputs.batchesToDeserialize != 0
id: remove-batches
run: |
node ./scripts/actions/remove-completed-batch.js
fetch-machine-translated-content:
name: Fetch machine translated content
runs-on: ubuntu-latest
env:
TRANSLATION_VENDOR_PROJECT: ${{ secrets.TRANSLATION_VENDOR_MT_PROJECT }}
TRANSLATION_VENDOR_USER: ${{ secrets.TRANSLATION_VENDOR_MT_USER }}
TRANSLATION_VENDOR_SECRET: ${{ secrets.TRANSLATION_VENDOR_MT_SECRET }}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Fetches translated content and deserializes
id: fetch-deserialize
run: |
node ./scripts/actions/check-job-progress.js
- name: Commit changes
id: commit-changes
if: steps.fetch-deserialize.outputs.batchesToDeserialize != 0
run: |
git config --local user.email "${{ env.BOT_EMAIL }}"
git config --local user.name "${{ env.BOT_NAME }}"
git add ./src/i18n/content
git commit -m 'chore: add translations'
echo "::set-output name=commit::true"
- name: Create Pull Request
if: steps.fetch-deserialize.outputs.batchesToDeserialize != 0
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
title: Updated translations - ${{ steps.date.outputs.date }} (machine translation)
body: ''
labels: translations
branch: translations
branch-suffix: short-commit-hash
base: develop
delete-branch: true
team-reviewers: developer-enablement

- name: Checkout repository
if: steps.fetch-deserialize.outputs.batchesToDeserialize != 0
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/send-content-to-machine-translate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Send content to be translated

on:
workflow_dispatch:
schedule:
# At 1 am everyday
- cron: '0 1 * * *'

env:
TRANSLATION_VENDOR_API_URL: ${{ secrets.TRANSLATION_VENDOR_API_URL }}
TRANSLATION_VENDOR_PROJECT: ${{ secrets.TRANSLATION_VENDOR_MT_PROJECT }}
TRANSLATION_VENDOR_USER: ${{ secrets.TRANSLATION_VENDOR_MT_USER }}
TRANSLATION_VENDOR_SECRET: ${{ secrets.TRANSLATION_VENDOR_MT_SECRET }}
DB_CONNECTION_INFO: ${{ secrets.DB_CONNECTION_INFO }}

jobs:
send-content:
name: Send content
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile

- name: Get content to be translated and send to vendor
run: node ./scripts/actions/send-and-update-translation-queue.js

0 comments on commit 82c7feb

Please sign in to comment.