name: Build Hexo Site

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

jobs:
  build:
    runs-on: ubuntu-latest

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

      - name: Install dependencies
        run: npm install

      - name: Build Hexo
        run: npm run build

      - name: Deploy to 1Panel website
        run: |
          SITE_DIR="/opt/1panel/apps/openresty/openresty/www/sites/blog.makefire.fun/index"

          rm -rf ${SITE_DIR}/*
          cp -r public/* ${SITE_DIR}/

          echo "✅ 构建完成！"
          ls -la ${SITE_DIR}
