Add workflows to push and pull translations from Transifex and check source file is updated when necessary

This commit is contained in:
Silvano Cerza 2021-10-11 12:37:26 +02:00 committed by Silvano Cerza
parent b83702fde3
commit ea2aeec69b
3 changed files with 135 additions and 0 deletions

67
.github/workflows/check-i18n-task.yml vendored Normal file
View File

@ -0,0 +1,67 @@
name: Check Internationalization
env:
# See: https://github.com/actions/setup-go/tree/v2#readme
GO_VERSION: '1.16'
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
create:
push:
paths:
- '.github/workflows/check-i18n-task.ya?ml'
- 'package.json'
- '**/package.json'
- '**.ts'
- 'i18n/**'
pull_request:
paths:
- '.github/workflows/check-i18n-task.ya?ml'
- 'package.json'
- '**/package.json'
- '**.ts'
- 'i18n/**'
workflow_dispatch:
repository_dispatch:
jobs:
run-determination:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.determination.outputs.result }}
steps:
- name: Determine if the rest of the workflow should run
id: determination
run: |
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
if [[ \
"${{ github.event_name }}" != "create" || \
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
]]; then
# Run the other jobs.
RESULT="true"
else
# There is no need to run the other jobs.
RESULT="false"
fi
echo "::set-output name=result::$RESULT"
check:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: '12.14.1'
registry-url: 'https://registry.npmjs.org'
- name: Check for errors
run: yarn i18n:check

30
.github/workflows/i18n-nightly-push.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: i18n-nightly-push
on:
schedule:
# run every day at 1AM
- cron: '0 1 * * *'
jobs:
push-to-transifex:
# This workflow is only of value to the arduino/arduino-ide repository and
# would always fail in forks
if: github.repository == 'arduino/arduino-ide'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: '12.14.1'
registry-url: 'https://registry.npmjs.org'
- name: Run i18n:push script
run: yarn run i18n:push
env:
TRANSIFEX_ORGANIZATION: ${{ secrets.TRANSIFEX_ORGANIZATION }}
TRANSIFEX_PROJECT: ${{ secrets.TRANSIFEX_PROJECT }}
TRANSIFEX_RESOURCE: ${{ secrets.TRANSIFEX_RESOURCE }}
TRANSIFEX_API_KEY: ${{ secrets.TRANSIFEX_API_KEY }}

38
.github/workflows/i18n-weekly-pull.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: i18n-weekly-pull
on:
schedule:
# run every monday at 2AM
- cron: '0 2 * * 1'
jobs:
pull-from-transifex:
# This workflow is only of value to the arduino/arduino-ide repository and
# would always fail in forks
if: github.repository == 'arduino/arduino-ide'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: '12.14.1'
registry-url: 'https://registry.npmjs.org'
- name: Run i18n:pull script
run: yarn run i18n:pull
env:
TRANSIFEX_ORGANIZATION: ${{ secrets.TRANSIFEX_ORGANIZATION }}
TRANSIFEX_PROJECT: ${{ secrets.TRANSIFEX_PROJECT }}
TRANSIFEX_RESOURCE: ${{ secrets.TRANSIFEX_RESOURCE }}
TRANSIFEX_API_KEY: ${{ secrets.TRANSIFEX_API_KEY }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Updated translation files
title: Updated translation files
branch: i18n/translations-update
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>