name: Deploy Blog

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy blog
        run: |
          cd /tmp
          rm -rf blog-build
          git clone http://192.168.0.14:3000/jawhng/jawhng-blog.git blog-build
          cd blog-build

          export NVM_DIR="/home/jawhng/.nvm"
          [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

          pnpm install --frozen-lockfile
          pnpm run build

          rm -rf /deploy/blog/*
          cp -r build/* /deploy/blog/

          echo "✅ Blog deployed successfully at $(date)"
