on:
  push:
    branches:
      - main
    paths:
      - TestVelGameServer/**
jobs:
  split-upm:
    name: split upm branch
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
          token: ${{ secrets.WORKFLOW_TOKEN }}
      - name: split upm branch
        run: |
          git subtree split -P "$PKG_ROOT" -b upm
          git checkout upm
          if [[ -d "Samples" ]]; then
            git mv Samples Samples~
            rm -f Samples.meta
            git config --global user.name 'github-bot'
            git config --global user.email 'github-bot@users.noreply.github.com'
            git commit -am "Rename Samples to Samples~"
          fi
          git push -f -u origin upm
        env:
          PKG_ROOT: TestVelGameServer/Packages/VelNetUnity
