forked from work-in-progress-team/RepoInterviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yml
More file actions
63 lines (58 loc) · 2.11 KB
/
cloudbuild.yml
File metadata and controls
63 lines (58 loc) · 2.11 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
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/github-token/versions/latest
env: GITHUB_TOKEN
steps:
# get gcp info with debug
- name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- -c
- |
echo ">> GITHUB_TOKEN length: ${#GITHUB_TOKEN}"
git config --global url."https://oauth2:$$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"
echo ">> Git config set:"
git config --global -l
echo ">> Starting submodule clone"
git submodule update --init --recursive
secretEnv: ['GITHUB_TOKEN']
# build docker
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'-t', 'asia-northeast1-docker.pkg.dev/$PROJECT_ID/repointerviewer/backend:$SHORT_SHA',
'./backend'
]
# push docker
- name: 'gcr.io/cloud-builders/docker'
args: [
'push',
'asia-northeast1-docker.pkg.dev/$PROJECT_ID/repointerviewer/backend:$SHORT_SHA'
]
# make release
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: bash
args:
- -c
- |
export PROJECT_ID=repointerviewer
IMAGE_PATH=asia-northeast1-docker.pkg.dev/${PROJECT_ID}/repointerviewer/backend
DIGEST=$(gcloud artifacts docker images describe asia-northeast1-docker.pkg.dev/${PROJECT_ID}/repointerviewer/backend:$SHORT_SHA \
--format="value(image_summary.digest)")
if [ "$BRANCH_NAME" = "develop" ]; then
PIPELINE_NAME="repointerviewer-pipeline-stg"
elif [ "$BRANCH_NAME" = "main" ]; then
PIPELINE_NAME="repointerviewer-pipeline-prod"
else
echo "Branch $BRANCH_NAME is not a deployable branch."
exit 0
fi
gcloud deploy releases create release-$(date +%s) \
--delivery-pipeline=$$PIPELINE_NAME \
--region=asia-northeast1 \
--project=${PROJECT_ID} \
--source=.gcp_infra \
--skaffold-file=skaffold.yaml \
--images=backend=asia-northeast1-docker.pkg.dev/${PROJECT_ID}/repointerviewer/backend@$$DIGEST
options:
logging: CLOUD_LOGGING_ONLY