name: SSH Frontend Deploy

on:
  push:
    branches:
      - main

jobs:
  ssh-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Write SSH Key
        run: |
          echo "$SSH_PRIVATE_KEY" > id_rsa
          chmod 600 id_rsa
        env:
          SSH_PRIVATE_KEY: ${{ vars.SSH_PRIVATE_KEY }}

      - name: Run SSH Deploy Script
        run: |
          ssh -i id_rsa -o StrictHostKeyChecking=no ${{ vars.SSH_USER }}@${{ vars.SSH_HOST }} "cd /root/timelapse-frontend && ./deploy.sh"
