-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.ps1
More file actions
55 lines (46 loc) · 1.84 KB
/
deploy.ps1
File metadata and controls
55 lines (46 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Math Mentor Deployment Script
$PROJECT_ID = "firstproject-c5ac2"
$REGION = "us-central1"
$SERVICE_NAME = "math-mentor"
Write-Host "Deploying MathPilot to Cloud Run" -ForegroundColor Cyan
# Check for gcloud
if (-not (Get-Command "gcloud" -ErrorAction SilentlyContinue)) {
Write-Error "Google Cloud CLI (gcloud) is not installed."
exit 1
}
# Login & Project Setup
gcloud auth login
gcloud config set project $PROJECT_ID
# Load environment variables from .env
$envVars = @{}
if (Test-Path ".env") {
Get-Content .env | ForEach-Object {
if ($_ -match '^([^#=]+)=(.*)$') {
$key = $matches[1].Trim()
$value = $matches[2].Trim().Trim('"')
$envVars[$key] = $value
}
}
}
# Prompt for missing required vars
if (-not $envVars["GEMINI_API_KEY"]) {
$envVars["GEMINI_API_KEY"] = Read-Host "Please enter your GEMINI_API_KEY"
}
if (-not $envVars["GOOGLE_CLIENT_ID"] -or $envVars["GOOGLE_CLIENT_ID"] -eq "your_google_oauth_client_id_here") {
Write-Host "WARNING: GOOGLE_CLIENT_ID not found in .env" -ForegroundColor Yellow
Write-Host "Get it from: https://console.cloud.google.com/apis/credentials?project=$PROJECT_ID" -ForegroundColor Yellow
$envVars["GOOGLE_CLIENT_ID"] = Read-Host "Please enter your GOOGLE_CLIENT_ID"
}
# Build substitutions string for Cloud Build
$substitutions = ($envVars.GetEnumerator() | ForEach-Object {
"_$($_.Key.ToUpper())=$($_.Value)"
}) -join ","
Write-Host "Deploying with configuration:" -ForegroundColor Cyan
$envVars.Keys | ForEach-Object { Write-Host " - $_" -ForegroundColor Gray }
# Deploy using Cloud Build with substitutions
Write-Host "Starting Cloud Build deployment..." -ForegroundColor Cyan
gcloud builds submit `
--config=cloudbuild.yaml `
--substitutions="$substitutions" `
--region=$REGION
Write-Host "Deployment Complete" -ForegroundColor Green