110 lines
3.5 KiB
YAML
110 lines
3.5 KiB
YAML
name: 'Pull docs translations from Crowdin'
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 */2 * * *' # Every two hours
|
|
workflow_dispatch:
|
|
inputs:
|
|
force_pull:
|
|
description: 'Force pull translations regardless of status'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
workflow_call:
|
|
inputs:
|
|
force_pull:
|
|
description: 'Force pull translations regardless of status'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
jobs:
|
|
pull_docs_translations:
|
|
name: Pull docs translations
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ github.token }}
|
|
ref: ${{ github.ref }}
|
|
|
|
- name: Setup i18n branch
|
|
run: |
|
|
git fetch origin i18n || true
|
|
git checkout -B i18n origin/i18n || git checkout -b i18n
|
|
|
|
- name: Configure git
|
|
run: |
|
|
git config --global user.name 'github-actions'
|
|
git config --global user.email '[email protected]'
|
|
|
|
- name: Stash any changes before pulling translations
|
|
run: |
|
|
git add .
|
|
git stash || true
|
|
|
|
- name: Pull translated docs from Crowdin
|
|
if: inputs.force_pull == true || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
|
|
uses: crowdin/github-action@v2
|
|
with:
|
|
upload_sources: false
|
|
upload_translations: false
|
|
download_translations: true
|
|
download_language: fr
|
|
source: 'packages/twenty-docs/**/*.mdx'
|
|
translation: 'packages/twenty-docs/l/%two_letters_code%/**/%original_file_name%'
|
|
export_only_approved: false
|
|
localization_branch_name: i18n
|
|
base_url: 'https://twenty.api.crowdin.com'
|
|
skip_untranslated_files: true
|
|
push_translations: false
|
|
create_pull_request: false
|
|
skip_ref_checkout: true
|
|
dryrun_action: false
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
CROWDIN_PROJECT_ID: '1'
|
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
|
|
- name: Fix file permissions
|
|
run: sudo chown -R runner:docker . || true
|
|
|
|
- name: Fix translated documentation links
|
|
run: bash packages/twenty-docs/scripts/fix-translated-links.sh
|
|
|
|
- name: Check for changes and commit
|
|
id: check_changes
|
|
run: |
|
|
git add .
|
|
if ! git diff --staged --quiet --exit-code; then
|
|
git commit -m "chore: update docs translations from Crowdin and fix internal links"
|
|
echo "changes_detected=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "changes_detected=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Push changes
|
|
if: steps.check_changes.outputs.changes_detected == 'true'
|
|
run: git push origin HEAD:i18n
|
|
|
|
- name: Create pull request
|
|
if: steps.check_changes.outputs.changes_detected == 'true'
|
|
run: |
|
|
if git diff --name-only origin/main..HEAD | grep -q .; then
|
|
gh pr create -B main -H i18n --title 'i18n - docs translations' --body 'Created by Github action' || true
|
|
else
|
|
echo "No file differences between branches, skipping PR creation"
|
|
fi
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|