name: Build Hexo Site

on:
  push:
    branches: [main, master]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        run: |
          git clone "http://gitea:3000/${{ gitea.repository }}.git" .
          git checkout "${{ gitea.sha }}"

      - name: Install Node.js & Build
        run: |
          node -v
          npm install
          npm run build

      - name: Deploy
        run: |
          rm -rf /home/ubuntu/html/*
          cp -r public/* /home/ubuntu/html/
          echo "✅ 构建完成！"