-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
executable file
·75 lines (68 loc) · 2.67 KB
/
cloudbuild.yaml
File metadata and controls
executable file
·75 lines (68 loc) · 2.67 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
steps:
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', '${_REGION}-docker.pkg.dev/$PROJECT_ID/cloud-run-source-deploy/bsod-analyzer:latest', '.']
# Push the container image to Artifact Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', '${_REGION}-docker.pkg.dev/$PROJECT_ID/cloud-run-source-deploy/bsod-analyzer:latest']
# Deploy container image to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'bsod-analyzer'
- '--image'
- '${_REGION}-docker.pkg.dev/$PROJECT_ID/cloud-run-source-deploy/bsod-analyzer:latest'
- '--region'
- '${_REGION}'
- '--platform'
- 'managed'
- '--allow-unauthenticated'
- '--port'
- '8080'
- '--max-instances'
- '10'
- '--min-instances'
- '1'
- '--memory'
- '1024Mi'
- '--cpu-throttling'
- '--cpu-boost'
- '--set-env-vars'
- 'NODE_ENV=production'
- '--update-secrets'
- 'GEMINI_API_KEY=gemini-api-key:latest,TURNSTILE_SECRET_KEY=turnstile-secret-key:latest,SESSION_SECRET=session-secret:latest,WINDBG_API_KEY=windbg-api-key:latest,UPSTASH_REDIS_REST_URL=upstash-redis-url:latest,UPSTASH_REDIS_REST_TOKEN=upstash-redis-token:latest'
# Purge Cloudflare cache after deployment
- name: 'gcr.io/cloud-builders/curl'
entrypoint: 'bash'
args:
- '-c'
- |
echo "🧹 Purging Cloudflare cache for bsod.windowsforum.com..."
RESPONSE=$$(curl -s -w "\n%%{http_code}" -X POST \
"https://api.cloudflare.com/client/v4/zones/$${CLOUDFLARE_ZONE_ID}/purge_cache" \
-H "Authorization: Bearer $${CLOUDFLARE_PURGE_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"hosts":["bsod.windowsforum.com"]}')
HTTP_CODE=$$(echo "$$RESPONSE" | tail -n1)
if [ "$$HTTP_CODE" = "200" ]; then
echo "✅ Cloudflare cache purged successfully"
else
echo "❌ Cloudflare cache purge failed with HTTP $$HTTP_CODE"
echo "Stale HTML in CDN will cause blank pages for users."
exit 1
fi
secretEnv: ['CLOUDFLARE_PURGE_TOKEN', 'CLOUDFLARE_ZONE_ID']
substitutions:
_REGION: us-east1
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/cloudflare-purge-token/versions/latest
env: 'CLOUDFLARE_PURGE_TOKEN'
- versionName: projects/$PROJECT_ID/secrets/cloudflare-zone-id/versions/latest
env: 'CLOUDFLARE_ZONE_ID'
options:
logging: CLOUD_LOGGING_ONLY
images:
- '${_REGION}-docker.pkg.dev/$PROJECT_ID/cloud-run-source-deploy/bsod-analyzer:latest'