name: "Crowdin: Upload source"

on:
  push:
    branches: [ master ]
    paths: [ 'resources/languages/source.json' ]

jobs:
  upload:
    runs-on: ubuntu-latest
    container: devkitpro/devkitarm

    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false
          submodules: recursive

      - name: Setup environment
        run: git config --global safe.directory '*'

      - name: Install tools
        run: |
          apt-get update
          apt-get -y install python3 python3-pip p7zip-full libarchive13
          python3 -m pip install --upgrade pip setuptools --break-system-packages
          python3 -m pip install cryptography git+https://github.com/TuxSH/firmtool.git --break-system-packages

      - name: Build test
        run: |
          make release -j$(nproc)

      - name: Push to Crowdin
        uses: crowdin/github-action@v2
        with:
          upload_sources: true
        env:
          CROWDIN_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
