name: Update Submodule

on:
  repository_dispatch:
    types:
      - update-submodule

jobs:
  update-submodule:

    runs-on: ubuntu-latest

    permissions:
      contents: write
      pull-requests: write

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.PAT }}
          submodules: recursive

      - name: Authorize Git
        run: |
          git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
          git config --global user.name "$GITHUB_ACTOR"

      - name: Update Submodule
        run: |
          git submodule update  --init --recursive --remote -f
        env:
          GITHUB_TOKEN: ${{ secrets.PAT }}

      - name: Commit Changes
        run: |
          git commit -am "chore(submodule): Update Translation Data"
          git push origin main
        env:
          GITHUB_TOKEN: ${{ secrets.PAT }}