name: Upload Source Documents

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  push_files_to_crowdin:
    name: Push files to Crowdin
    if: github.repository == 'go-task/task'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Verify changed files
        id: changed-files
        uses: tj-actions/changed-files@v35
        with:
          files: |
            docs/docs
            docs/blog
            docs/i18n/en
            docs/src/pages

      - name: Install Task
        uses: arduino/setup-task@v1
        with:
          version: 3.x
          repo-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload source documents
        if: steps.changed-files.outputs.any_changed == 'true'
        run: task crowdin:push
        env:
          CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
        working-directory: ./docs
