pipeline {
    agent any
    environment {
        DEPLOY_FRONTEND = '/mnt/h/bitforum'
    }
    stages {
        stage('Build') {
            steps {
                sh 'npm ci'
                sh 'npm run build'
            }
        }
        stage('Deploy') {
            steps {
                sh 'rsync -av --delete --exclude="web.config" --exclude="ecosystem.config.js" .next/standalone/ ${DEPLOY_FRONTEND}/'
                sh 'rsync -av --delete .next/static/ ${DEPLOY_FRONTEND}/.next/static/'
                sh 'rsync -av --delete public/ ${DEPLOY_FRONTEND}/public/'
            }
        }
        stage('Restart Frontend') {
            steps {
                sh 'powershell.exe -ExecutionPolicy Bypass -File /mnt/h/bitforum/restart.ps1'
            }
        }
    }
    post {
        success { echo 'Frontend 배포 성공!' }
        failure { echo 'Frontend 배포 실패 - 로그를 확인하세요.' }
    }
}
