name: Deploy AstraOS Panel

on:
  push:
    branches: ["main"]

jobs:
  deploy:
    runs-on: docker
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - name: Install rsync + ssh
        run: |
          apt-get update
          apt-get install -y rsync openssh-client

      - name: Add SSH key
        run: |
          mkdir -p ~/.ssh
          echo "${{ secrets.DEPLOY_KEY_B64 }}" | base64 -d > ~/.ssh/id_ed25519
          chmod 600 ~/.ssh/id_ed25519
          ssh-keyscan -p 22 116.203.131.247 >> ~/.ssh/known_hosts

      - name: Deploy AstraOS folder to server
        run: |
          rsync -av \
            ./AstraOS/ astraos@116.203.131.247:/home/astraos/Astra-OS-Panel/