# Access the id_github file from Secret Manager, and setup SSH
options:
  default_logs_bucket_behavior: REGIONAL_USER_OWNED_BUCKET

steps:
- name: 'gcr.io/cloud-builders/gcloud:latest'
  entrypoint: 'bash'
  args:
    - '-c'
    - |
<<<<<<< HEAD
      gcloud compute scp --recurse ./* panera@api-service:/var/www/cojocaru.shop --zone=europe-west4-b
=======
      # Ensure the timezone is set correctly
      echo "America/New_York" > /etc/timezone
      ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime

- name: 'php:cli'  # Use a PHP CLI image
  entrypoint: 'bash'
  args:
    - '-c'
    - |
      # Copy your PHP script into the container
      cp /workspace/get_changed_files.php /get_changed_files.php
      # Run the PHP script
      php /get_changed_files.php
  
- name: 'gcr.io/cloud-builders/gcloud:latest'
  entrypoint: 'bash'
  args:
    - '-c'
    - |
      # Display the list of changed files
      echo "Changed files:"
      cat changed_files.txt
      
      # Read changed files from changed_files.txt and upload them
      while IFS= read -r file; do
        echo "Uploading: $file"  # Display the file being uploaded
        
        remote_dir="/var/www/cojocaru/$(dirname $file)"
        echo "Ensuring directory exists: $remote_dir"

        # Now upload the filessss
        gcloud compute scp "$file" bryantbradley@back-instance-20241014-132741:"$remote_dir/$(basename "$file")" \
          --zone=us-central1-c || true

      done < changed_files.txt
