-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
58 lines (48 loc) · 2.03 KB
/
cloudbuild.yaml
File metadata and controls
58 lines (48 loc) · 2.03 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
# Minimal Cloud Build configuration for production deployment
# This file only handles deployment of pre-built Docker images from GitHub Actions
substitutions:
_DEPLOY_REGION: us-central1
_PLATFORM: managed
_SERVICE_NAME: mento-analytics-api
_IMAGE_TAG: ${_IMAGE_TAG}
_COMMIT_SHA: ${_COMMIT_SHA}
options:
logging: CLOUD_LOGGING_ONLY
substitutionOption: ALLOW_LOOSE
steps:
# Step 1: Deploy to Cloud Run using pre-built image
- name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim
id: deploy
entrypoint: bash
args:
- -c
- |
echo "Deploying pre-built image: ${_IMAGE_TAG}"
# The source files are already in /workspace from Cloud Build
# Source the centralized environment configuration
cd /workspace && source ./scripts/env-config.sh
# Build the environment variables string for production
# Override environment-specific values
export NODE_ENV="production"
export ENVIRONMENT="production"
export SENTRY_ENVIRONMENT="production"
# Build the environment variables string
ENV_VARS=$$(build_env_vars_string "main" "main" "${_COMMIT_SHA}")
# Debug: Print the environment variables
echo "=== Environment variables being set ==="
echo "$$ENV_VARS" | tr ',' '\n'
echo "=== End of environment variables ==="
gcloud run deploy ${_SERVICE_NAME} \
--platform=managed \
--image="${_IMAGE_TAG}" \
--labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=${_COMMIT_SHA},gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID \
--region=${_DEPLOY_REGION} \
--quiet \
--set-env-vars="$$ENV_VARS" \
--set-secrets="EXCHANGE_RATES_API_KEY=exchange-rates-api-key-prod:latest,COINMARKETCAP_API_KEY=coinmarketcap-api-key-prod:latest,CELO_RPC_URL=celo-rpc-url-prod:latest,ETH_RPC_URL=eth-rpc-url-prod:latest"
# Tags for this build
tags:
- gcp-cloud-build-deploy-cloud-run
- gcp-cloud-build-deploy-cloud-run-managed
- ${_SERVICE_NAME}
timeout: 300s