video-accessibility/infra/cloud-cdn/cloudbuild-spa.yaml
2025-08-24 16:28:33 -05:00

63 lines
No EOL
1.7 KiB
YAML

steps:
# Install frontend dependencies
- name: 'node:20'
entrypoint: 'npm'
args: ['ci']
dir: 'frontend'
id: 'install-deps'
# Build frontend
- name: 'node:20'
entrypoint: 'npm'
args: ['run', 'build']
dir: 'frontend'
env:
- 'VITE_API_URL=https://accessible-video-api-${_REGION}.a.run.app'
- 'VITE_ENVIRONMENT=production'
- 'VITE_SENTRY_DSN=${_SENTRY_DSN}'
id: 'build-frontend'
waitFor: ['install-deps']
# Deploy to GCS bucket
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'bash'
args:
- '-c'
- |
# Sync files to bucket
gsutil -m rsync -r -d frontend/dist gs://accessible-video-spa-${PROJECT_ID}/
# Set cache headers for static assets
gsutil -m setmeta -h "Cache-Control:public, max-age=31536000, immutable" \
gs://accessible-video-spa-${PROJECT_ID}/assets/**
# No cache for HTML files
gsutil -m setmeta -h "Cache-Control:no-cache, no-store, must-revalidate" \
-h "Pragma:no-cache" \
-h "Expires:0" \
gs://accessible-video-spa-${PROJECT_ID}/*.html
id: 'deploy-spa'
waitFor: ['build-frontend']
# Invalidate CDN cache (if CDN is configured)
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'gcloud'
args:
- 'compute'
- 'url-maps'
- 'invalidate-cdn-cache'
- 'accessible-video-spa-url-map'
- '--path=/*'
- '--global'
id: 'invalidate-cache'
waitFor: ['deploy-spa']
substitutions:
_REGION: 'us-central1'
_SENTRY_DSN: '' # Set in Cloud Build trigger
options:
machineType: 'E2_STANDARD_2'
diskSizeGb: '50'
timeout: '600s'