name: Deploy App

on:
  push:
    branches:
      - CICD

jobs:
  deploy:
    runs-on: kyc_runner
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          path: myapp

      - name: Print working directory
        run: pwd && ls -lah

      - name: Move app to target directory
        run: |
          sudo rm -rf /opt/myapp  # Remove old deployment
          sudo mv ${{ github.workspace }}/myapp /opt/myapp
          sudo chown -R $USER:$USER /opt/myapp

      - name: Start application with Docker Compose
        run: |
          cd /opt/myapp
          docker-compose up --build -d

      - name: Verify running containers
        run: docker ps -a
