on:
  push:
    branches: [main]
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v4

      - name: Setup node
        uses: https://github.com/actions/setup-node@v4
        with:
          node-version: 18

      - name: Build
        run: |
          cd src
          npm ci
          npx presskit build --output ../out --pretty-links --collapse-menu --clean-build-folder
          cp .htaccess ../out

      - name: Deploy
        run: |
          apt update && apt install -y rsync
          curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && sudo dpkg -i cloudflared.deb
          echo "${{ secrets.ELLBOT_KEY }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
          rsync -rv --delete -e 'ssh -o "ProxyCommand cloudflared access ssh --hostname %h" -o "StrictHostKeyChecking=no"' main/_site/ ellbot@ssh.ellpeck.de:/var/www/press    
