name: Deploy to VelNet Oracle server (Pocketbase edition)

on:
  push:
    branches: ["main"]
    paths: ["velconnect/**"]
jobs:
  run_pull:
    name: Pull new version on Oracle
    runs-on: ubuntu-latest
    steps:
      - name: install ssh keys
        run: |
          install -m 600 -D /dev/null ~/.ssh/id_rsa
          echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
          ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
      - name: connect and pull
        run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd /home/ubuntu/VEL-Connect-v4/velconnect && git pull && docker compose -p velconnect-v4 up -d --build && exit"
      - name: cleanup
        run: rm -rf ~/.ssh

