steps:
  #Clone the repository
  - name: gcr.io/cloud-builders/git
    args: ['clone', '--branch', 'tef_integration_baseline', 'https://source.developers.google.com/p/sa-test-gcp/r/tef-gcp-lz-gsr']
    id: 'check-out-source'

  - id: 'Install Tools and Perform Deployment'
    name: gcr.io/cloud-builders/gcloud
    entrypoint: 'bash'
    args:
    - -c
    - |
      gcloud auth application-default login --impersonate-service-account sa-gcp-partners-test@sa-test-gcp.iam.gserviceaccount.com --quiet 
      curl -fsSL https://apt.releases.hashicorp.com/gpg |  apt-key add -
      apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
      apt-get install -y wget unzip
      wget https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
      unzip terraform_1.6.0_linux_amd64.zip
      mv terraform /usr/local/bin/
      chmod +x /usr/local/bin/terraform
      terraform --version
      apt-get update && apt-get install dos2unix
      apt-get update && apt-get install google-cloud-sdk
      apt-get install google-cloud-cli-terraform-tools -y
      apt-get install jq -y
      apt update && apt install python3  # Installs latest Python 3 version
      ls -l
      # python3 ./fix_tfvars_symlinks.py .
      find . -type f -name "*.sh" | xargs chmod a+x
      find . -type f -name "*.sh" | xargs dos2unix
      export SUPER_ADMIN_EMAIL=$_SUPER_ADMIN_EMAIL
      export REGION=${_REGION}
      export ORG_ID=${_ORG_ID}
      export ROOT_FOLDER_ID=${_ROOT_FOLDER_ID}
      export BILLING_ID=${_BILLING_ID}
      export DOMAIN=${_DOMAIN}
      echo ${_DOMAIN}
      echo $_SUPER_ADMIN_EMAIL
      echo ${_REGION}
      echo ${_ORG_ID}
      echo ${_ROOT_FOLDER_ID}
      echo ${_BILLING_ID}
      chmod +x automation-scripts/whole.sh
      chmod +x ./0-bootstrap/prep.sh
      sh ./automation-scripts/whole.sh 

logsBucket: 'gs://tef-cb-logs-bucket/cloudbuild-logs'