Translations cleaning / workflows (#10125)
This commit is contained in:
48
.github/workflows/i18n-compile.yaml
vendored
Normal file
48
.github/workflows/i18n-compile.yaml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
name: 'Compile translations'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['i18n']
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
compile_translations:
|
||||
name: Compile translations
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
ref: i18n
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/workflows/actions/yarn-install
|
||||
|
||||
- name: Build twenty-shared
|
||||
run: npx nx build twenty-shared
|
||||
|
||||
- name: Compile translations
|
||||
id: compile_translations
|
||||
run: |
|
||||
npx nx run twenty-server:lingui:compile
|
||||
npx nx run twenty-emails:lingui:compile
|
||||
npx nx run twenty-front:lingui:compile
|
||||
|
||||
- name: Check and commit compiled files
|
||||
run: |
|
||||
git config --global user.name 'github-actions'
|
||||
git config --global user.email 'github-actions@twenty.com'
|
||||
git add .
|
||||
if ! git diff --staged --quiet --exit-code; then
|
||||
git commit -m "chore: compile translations"
|
||||
git push origin HEAD:i18n
|
||||
fi
|
||||
71
.github/workflows/i18n-force-pull.yml
vendored
71
.github/workflows/i18n-force-pull.yml
vendored
@ -1,71 +0,0 @@
|
||||
# This is similar to the "Pull Translations" workflow, but without the conditional check to allow us to
|
||||
# forcefully pull down translations from Crowdin and create a PR regardless if all the translations are fulfilled.
|
||||
#
|
||||
# Intended to be used when we manually update translations in Crowdin UI and want to pull those down when
|
||||
# they already exist.
|
||||
|
||||
name: 'Force pull translations'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
pull_translations:
|
||||
name: Force pull translations
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/workflows/actions/yarn-install
|
||||
|
||||
- name: Build twenty-shared
|
||||
run: npx nx build twenty-shared
|
||||
|
||||
- name: Pull translations from Crowdin
|
||||
uses: crowdin/github-action@v2
|
||||
with:
|
||||
upload_sources: false
|
||||
upload_translations: false
|
||||
download_translations: true
|
||||
export_only_approved: false
|
||||
localization_branch_name: chore/translations
|
||||
commit_message: 'chore: add translations'
|
||||
pull_request_title: 'chore: add translations'
|
||||
base_url: 'https://twenty.api.crowdin.com'
|
||||
|
||||
env:
|
||||
# A classic GitHub Personal Access Token with the 'repo' scope selected (the user should have write access to the repository).
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
# A numeric ID, found at https://crowdin.com/project/<projectName>/tools/api
|
||||
CROWDIN_PROJECT_ID: '1'
|
||||
|
||||
# Visit https://crowdin.com/settings#api-key to create this token
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
|
||||
- name: Compile and commit updated translations
|
||||
run: |
|
||||
git fetch origin chore/translations
|
||||
git checkout chore/translations
|
||||
npx nx run twenty-server:lingui:compile
|
||||
npx nx run twenty-emails:lingui:compile
|
||||
npx nx run twenty-front:lingui:compile
|
||||
git config --global user.name 'Crowdin Bot'
|
||||
git config --global user.email 'support+bot@crowdin.com'
|
||||
git add .
|
||||
git commit -m "chore: compile translations"
|
||||
git push origin chore/translations
|
||||
35
.github/workflows/i18n-pull.yaml
vendored
35
.github/workflows/i18n-pull.yaml
vendored
@ -1,4 +1,5 @@
|
||||
# Pull down translations from Crowdin every two hours or when triggered manually.
|
||||
# When force_pull input is true, translations will be pulled regardless of compilation status.
|
||||
|
||||
name: 'Pull translations'
|
||||
|
||||
@ -6,7 +7,19 @@ on:
|
||||
schedule:
|
||||
- cron: '0 */2 * * *' # Every two hours.
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force_pull:
|
||||
description: 'Force pull translations regardless of compilation status'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
workflow_call:
|
||||
inputs:
|
||||
force_pull:
|
||||
description: 'Force pull translations regardless of compilation status'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
@ -43,16 +56,16 @@ jobs:
|
||||
continue-on-error: true
|
||||
|
||||
- name: Pull translations from Crowdin
|
||||
if: steps.compile_translations.outcome == 'failure'
|
||||
if: inputs.force_pull || steps.compile_translations.outcome == 'failure'
|
||||
uses: crowdin/github-action@v2
|
||||
with:
|
||||
upload_sources: false
|
||||
upload_translations: false
|
||||
download_translations: true
|
||||
export_only_approved: false
|
||||
localization_branch_name: chore/translations
|
||||
commit_message: 'chore: add translations'
|
||||
pull_request_title: 'chore: add translations'
|
||||
localization_branch_name: i18n
|
||||
commit_message: 'i18n - translations'
|
||||
pull_request_title: 'i18n - translations'
|
||||
base_url: 'https://twenty.api.crowdin.com'
|
||||
auto_approve_imported: false
|
||||
import_eq_suggestions: false
|
||||
@ -72,17 +85,3 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
CROWDIN_PROJECT_ID: '1'
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
|
||||
- name: Compile and commit updated translations
|
||||
if: steps.compile_translations.outcome == 'failure'
|
||||
run: |
|
||||
git fetch origin chore/translations
|
||||
git checkout chore/translations
|
||||
npx nx run twenty-server:lingui:compile
|
||||
npx nx run twenty-emails:lingui:compile
|
||||
npx nx run twenty-front:lingui:compile
|
||||
git config --global user.name 'Crowdin Bot'
|
||||
git config --global user.email 'support+bot@crowdin.com'
|
||||
git add .
|
||||
git commit -m "chore: compile translations"
|
||||
git push origin chore/translations
|
||||
@ -1,4 +1,4 @@
|
||||
name: 'Extract and upload translations'
|
||||
name: 'Extract translations when there is a push to main, and upload them to Crowdin'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@ -21,7 +21,13 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
ref: ${{ github.head_ref || github.ref_name }}
|
||||
ref: i18n
|
||||
|
||||
- name: Merge main into i18n
|
||||
run: |
|
||||
git fetch origin main
|
||||
git checkout i18n
|
||||
git merge main
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/workflows/actions/yarn-install
|
||||
@ -36,35 +42,37 @@ jobs:
|
||||
npx nx run twenty-front:lingui:extract
|
||||
|
||||
- name: Check and commit any files created
|
||||
id: check_changes
|
||||
run: |
|
||||
git config --global user.name 'github-actions'
|
||||
git config --global user.email 'github-actions@twenty.com'
|
||||
git add .
|
||||
if ! git diff --staged --quiet --exit-code; then
|
||||
git commit -m "chore: extract translations"
|
||||
git push origin HEAD:${{ github.head_ref || github.ref_name }}
|
||||
git push origin HEAD:i18n
|
||||
echo "changes_detected=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "changes_detected=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Compile translations
|
||||
id: compile_translations
|
||||
run: |
|
||||
npx nx run twenty-server:lingui:compile
|
||||
npx nx run twenty-emails:lingui:compile
|
||||
npx nx run twenty-front:lingui:compile
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload missing translations
|
||||
if: ${{ steps.compile_translations.outcome == 'failure' }}
|
||||
if: steps.check_changes.outputs.changes_detected == 'true'
|
||||
uses: crowdin/github-action@v2
|
||||
with:
|
||||
upload_sources: true
|
||||
upload_translations: true
|
||||
download_translations: false
|
||||
localization_branch_name: chore/translations
|
||||
localization_branch_name: i18n
|
||||
base_url: 'https://twenty.api.crowdin.com'
|
||||
env:
|
||||
# A numeric ID, found at https://crowdin.com/project/<projectName>/tools/api
|
||||
CROWDIN_PROJECT_ID: 1
|
||||
|
||||
# Visit https://crowdin.com/settings#api-key to create this token
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
|
||||
- name: Create a pull request
|
||||
if: steps.check_changes.outputs.changes_detected == 'true'
|
||||
run: gh pr create -B main -H i18n --title 'i18n - translations' --body 'Created by Github action' || true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
Reference in New Issue
Block a user