Skip to content

Commit

Permalink
chore: modify workflows for machine translation
Browse files Browse the repository at this point in the history
* created separate "send" workflow since we want to send documents for
  machine translation on a different schedule than normal.
* updated "queue" workflow to have both project_ids since it needs both
  in order to correctly populate data for the new project_id column.
* updated "download" workflow to have a separate job for downloading &
  PRing machine translated documents.
  • Loading branch information
moonlight-komorebi committed Nov 12, 2021
1 parent 915e8b8 commit a8829ea
Show file tree
Hide file tree
Showing 3 changed files with 124 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
86 changes: 83 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,89 @@ 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

- 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 }}
body: ''
labels: translations
branch: translations
branch-suffix: short-commit-hash
base: develop
delete-branch: true

- 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
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 on the 1st and 15th day of a month
- 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 a8829ea

Please sign in to comment.