name: Deploy Hugo Site

on:
  push:
    branches:
      - main
# Test
jobs:
  deploy:
    runs-on: ubuntu-24.04

    container:
      image: klakegg/hugo:ext-alpine

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Hugo Build
        run: hugo

      - name: SSH vorbereiten
        run: |
          mkdir -p ~/.ssh
          echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
          chmod 600 ~/.ssh/id_ed25519

          echo "${{ secrets.KNOWN_HOSTS }}" > ~/.ssh/known_hosts
          chmod 644 ~/.ssh/known_hosts

      - name: Deploy via rsync
        run: |
          rsync -avz --delete \
            public/ \
            gitea-runner@webserver.hahmann-trier.local:/var/www/www-deepwatersurvival-de