image: php:7.4

pipelines:
  branches:
    dev:
      - step:
          name: Deploy to Dev
          caches:
            - composer
          script:
            - apt-get update && apt-get install -y sshpass zip unzip
            - ls -la # List the root directory
            - echo "Zipping files..."
            - zip -r deployment.zip ./* # Zip all files in the current directory
            - ls -la # List the directory to verify the zip file is created
            - echo "Uploading zip file..."
            - sshpass -p "$DEV_SFTP_PASS" sftp -o StrictHostKeyChecking=no -P $DEV_SFTP_PORT $DEV_SFTP_USER@$DEV_SFTP_HOST:$DEV_SFTP_PATH <<< $'put deployment.zip'
            - echo "Unzipping files on server..."
            - sshpass -p "$DEV_SFTP_PASS" ssh -o StrictHostKeyChecking=no -p $DEV_SFTP_PORT $DEV_SFTP_USER@$DEV_SFTP_HOST "unzip -o $DEV_SFTP_PATH/deployment.zip -d $DEV_SFTP_PATH && rm $DEV_SFTP_PATH/deployment.zip"
