image: ubuntu:latest

pipelines:
  branches:
    master:
      - step:
          name: Deploy to Production
          script:
            - apt-get update && apt-get install -y openssh-client rsync
            - echo "🚀 Starting Deployment to /opt/lampp/htdocs/newchange..."

            # Create SSH directory and set permissions
            - mkdir -p ~/.ssh
            - echo "${DEPLOY_PRIVATE_KEY}" > ~/.ssh/id_rsa
            - chmod 600 ~/.ssh/id_rsa

            # Add server to known hosts
            - ssh-keyscan -H 148.66.153.187 >> ~/.ssh/known_hosts

            # Deploy code to server
            - rsync -avz --delete ./ arnabpolley@148.66.153.187:/opt/lampp/htdocs/newchange/

            - echo "✅ Deployment completed successfully!"
