name: Copy Repo, Strip Functions and Git Commit
on:
  push:
    branches:
      - main
jobs:
  Copy-Repo-Strip-Functions:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v2
      - uses: conda-incubator/setup-miniconda@v2
        with:
          auto-update-conda: false
          activate-environment: strip
          environment-file: environment-strip-action.yaml
          python-version: 3.9
      - name: Run empty function
        shell: bash -l {0}
        run: |
          python -m libcst.tool codemod replace_functions.ReplaceFunctionCommand .
      - name: Clone & push to public repo
        shell: bash -l {0}
        env:
          DESTINATION_SSH_PRIVATE_KEY: ${{ secrets.DESTINATION_SSH_PRIVATE_KEY }}
        run: |
          git config --global user.name "bot"
          git config --global user.email "mark.szulyovszky@gmail.com.com"
          
          cd ..
          mkdir -p ~/.ssh
          echo "$DESTINATION_SSH_PRIVATE_KEY" | sed 's/\\n/\n/g' >~/.ssh/dst_rsa
          chmod 600 ~/.ssh/dst_rsa
          
          git clone -c core.sshCommand="/usr/bin/ssh -i ~/.ssh/dst_rsa" git@github.com:applied-exploration/drift.git
          rsync -aP --exclude=.git/** ./drift-private/* ./drift/
          
          cd drift
          git config core.sshCommand "/usr/bin/ssh -i ~/.ssh/dst_rsa"
          git add -A
          git commit -m "update"
          git push -u origin 'main'
