name: Deploy HouseHub

on:
  push:
    branches: [main, staging-perco, staging-fefe]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy via SSH
        uses: appleboy/ssh-action@v1.0.0
        with:
          host: 192.168.1.29
          username: perco
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          script: |
            BRANCH="${{ github.ref_name }}"
            case "$BRANCH" in
              main)
                cd /opt/container/househub
                git pull
                echo "✓ Production mise à jour"
                ;;
              staging-perco)
                cd /opt/container/househub-perco
                git pull origin staging-perco
                echo "✓ Staging Perco mis à jour"
                ;;
              staging-fefe)
                cd /opt/container/househub-fefe
                git pull origin staging-fefe
                echo "✓ Staging Fefe mis à jour"
                ;;
            esac
