steps:
  - name: "gcr.io/cloud-builders/gcloud"
    entrypoint: "bash"
    args:
      - "-c"
      - |
        gcloud compute ssh ibrat-dashboard-backend --zone "europe-north1-b" --project "$PROJECT_ID" --tunnel-through-iap --command '
          cd /home/suyunovshohjahon08/projects/learnuzbek-flutter-compiled

          sudo git config --global --add safe.directory /home/suyunovshohjahon08/projects/learnuzbek-flutter-compiled

          sudo git fetch origin
          sudo git reset --hard origin/main
          sudo git clean -fd

          sudo chown -R $(whoami):$(whoami) /home/suyunovshohjahon08/projects/learnuzbek-flutter-compiled

          sudo rm -rf /var/www/app-learnuzbek
          sudo mkdir -p /var/www/app-learnuzbek
          sudo cp -r ./* /var/www/app-learnuzbek/

          sudo nginx -t
          sudo systemctl restart nginx
        '

options:
  logging: CLOUD_LOGGING_ONLY