name: Build Site Main
on: 
  push:
    branches:
      - main

jobs:
  Build-Site:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Use Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '16.x'
      - run: npm install
      - run: npm run build

      - name: Upload via SFTP (lftp)
        run: |
          apt update && apt install -y lftp
          lftp -u "$SFTP_USER","$SFTP_PASSWORD" sftp://$SFTP_HOST <<EOF
          mirror -R --only-newer --verbose build /home/pettinattk/www
          quit
          EOF
        env:
          SFTP_HOST: ${{ secrets.SFTP_HOST }}
          SFTP_USER: ${{ secrets.SFTP_USER }}
          SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}