name: Sync Crowdin

on:
  schedule:
    - cron: "0 17 * * 6" # "At 17:00 on Saturday."
  workflow_dispatch:

permissions:
  contents: write

jobs:
  sync-crowdin:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Crowdin
        uses: crowdin/github-action@v2
        with:
          config: crowdin.yml
          upload_sources: true
          upload_translations: true
          download_translations: true
          push_translations: true
          localization_branch_name: main
          create_pull_request: false
          commit_message: 'chore(l10n): sync translations'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_ID }}
          CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
