-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
41 lines (37 loc) · 1.62 KB
/
cloudbuild.yaml
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
steps:
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
entrypoint: sh
args:
- -c
- |
docker build --build-arg MONGODB_URI --build-arg NEXTAUTH_SECRET --build-arg GITHUB_BRANCH=$BRANCH_NAME -t gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA .
secretEnv:
- 'MONGODB_URI'
- 'NEXTAUTH_SECRET'
# Push the container image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA']
# Deploy container image to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: sh
args:
- '-c'
- |
GITHUB_OWNER=$(echo ${REPO_FULL_NAME} | cut -d'/' -f1)
gcloud run deploy self-hosted-docker-demo --image gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA --region us-central1 --platform managed --allow-unauthenticated --update-env-vars MONGODB_URI=$$MONGODB_URI,NEXTAUTH_SECRET=$$NEXTAUTH_SECRET,GITHUB_PERSONAL_ACCESS_TOKEN=$$GITHUB_PERSONAL_ACCESS_TOKEN,GITHUB_OWNER=$$GITHUB_OWNER,GITHUB_REPO=$REPO_NAME,GITHUB_BRANCH=$BRANCH_NAME
secretEnv:
- 'MONGODB_URI'
- 'GITHUB_PERSONAL_ACCESS_TOKEN'
- 'NEXTAUTH_SECRET'
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_NUMBER/secrets/MONGODB_URI/versions/latest
env: 'MONGODB_URI'
- versionName: projects/$PROJECT_NUMBER/secrets/GITHUB_PERSONAL_ACCESS_TOKEN/versions/latest
env: 'GITHUB_PERSONAL_ACCESS_TOKEN'
- versionName: projects/$PROJECT_NUMBER/secrets/NEXTAUTH_SECRET/versions/latest
env: 'NEXTAUTH_SECRET'
options:
logStreamingOption: STREAM_ON
logging: CLOUD_LOGGING_ONLY