name: Build on Merge
on:
  push: 
    branches:
      - main
    paths-ignore:
      - 'docker/**'

jobs:
  deploy:
    runs-on: self-hosted
    steps:
      - name: Checkout code
        uses: actions/checkout@v5
      
      - name: Run rebuild script
        run: /root/patchmon/platform/scripts/app_build.sh ${{ github.ref_name }}
  
  rebuild-pmon:
    runs-on: self-hosted
    needs: deploy
    if: github.ref_name == 'dev'
    steps:
      - name: Rebuild pmon
        run: /root/patchmon/platform/scripts/manage_pmon_auto.sh
