92 lines
2.9 KiB
YAML
92 lines
2.9 KiB
YAML
name: 'Extract translations when there is a push to main, and upload them to Crowdin'
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
push:
|
|
branches: ['main']
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
extract_translations:
|
|
name: Extract and upload translations
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ github.token }}
|
|
ref: main
|
|
|
|
- name: Setup i18n branch
|
|
run: |
|
|
if ! git ls-remote --heads origin i18n | grep i18n; then
|
|
git checkout -b i18n
|
|
else
|
|
git fetch origin i18n
|
|
git checkout i18n
|
|
git merge origin/main
|
|
fi
|
|
|
|
- name: Install dependencies
|
|
uses: ./.github/workflows/actions/yarn-install
|
|
|
|
- name: Build dependencies
|
|
run: npx nx build twenty-shared
|
|
|
|
- name: Extract translations
|
|
run: |
|
|
npx nx run twenty-server:lingui:extract
|
|
npx nx run twenty-emails:lingui:extract
|
|
npx nx run twenty-front:lingui:extract
|
|
|
|
- name: 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 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"
|
|
echo "changes_detected=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "changes_detected=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Push changes and create remote branch if needed
|
|
if: steps.check_changes.outputs.changes_detected == 'true'
|
|
run: git push origin HEAD:i18n
|
|
|
|
- name: Upload missing translations
|
|
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: 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 }}
|
|
|
|
- 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 }}
|