on: [push]
jobs:
  build:
    runs-on: docker
    container.image: node:20-bookworm
    steps:
      - uses: actions/checkout@v4
      - run: npm install && npm run build
        name: NPM Install and Build
      - name: Setup SSH Key
        run: |
          mkdir -p ~/.ssh/
          echo "${{ secrets.SSHKEY }}" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
      - name: Push site to nginx
        run: | 
          apt update && apt install -y rsync
          rsync -avc -e "ssh -o StrictHostKeyChecking=no" --delete .vercel/output/static/* ${{secrets.USER}}@${{secrets.HOSTNAME}}:${{secrets.DESTPATH}}/.
      - name: Upload output
        uses: actions/upload-artifact@v3
        with:
          name: outputsite
          path: .vercel/output/static