name: Web Console Deploy (Vue 3 + Vite)
on:
  push:
    branches:
      - main
    paths:
      - 'web/**'
      - '.gitea/workflows/web-deploy.yml'

jobs:
  deploy:
    runs-on: arm
    container:
      image: catthehacker/ubuntu:act-latest
    steps:
      - name: 获取代码
        uses: actions/checkout@v4
      
      - name: 安装 Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
          cache-dependency-path: web/package-lock.json
          
      - name: 安装依赖并打包
        run: |
          cd web
          npm install
          npm run build
      
      - name: 准备部署文件夹
        run: |
          mkdir -p deploy_web
          cp -r web/dist/* deploy_web/

      - name: 部署静态文件到服务器
        uses: up9cloud/action-rsync@master
        env:
          USER: root
          HOST: 144.24.60.0
          KEY: ${{secrets.USAARMLOGIN_SSH_KEY}}
          ARGS: -avz --delete 
          SSH_ARGS: "-p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
          SOURCE: ./deploy_web/
          TARGET: /var/admin/InsightReply/web
          VERBOSE: true
