-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
66 lines (61 loc) · 1.99 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
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
# Access the id_github file from Secret Manager
steps:
- name: gcr.io/cloud-builders/gcloud
entrypoint: "bash"
args:
[
"-c",
"gcloud secrets versions access latest --secret=$_GITHUB_SECRET > /root/.ssh/id_github",
]
volumes:
- name: "ssh"
path: /root/.ssh
- name: gcr.io/cloud-builders/gcloud
entrypoint: "bash"
args:
[
"-c",
"gcloud secrets versions access latest --secret=$_BITBUCKET_SECRET > /root/.ssh/id_bitbucket",
]
volumes:
- name: "ssh"
path: /root/.ssh
# Set up git with key and domain
- name: gcr.io/cloud-builders/git
entrypoint: "bash"
args:
- "-c"
- |
chmod 600 /root/.ssh/id_github
chmod 600 /root/.ssh/id_bitbucket
cat <<EOF >/root/.ssh/config
IdentityFile /root/.ssh/id_bitbucket
IdentityFile /root/.ssh/id_github
EOF
ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
ssh-keyscan github.com >> /root/.ssh/known_hosts
volumes:
- name: "ssh"
path: /root/.ssh
# Run tests
- name: gcr.io/cloud-builders/docker
args: ['run', '-d', '--name=testdb', '--network=cloudbuild', '--env=POSTGRES_HOST_AUTH_METHOD=trust', 'postgres']
- name: 'python:3.8'
entrypoint: "bash"
args:
- "-c"
- 'pip install -r requirements.txt && pip install -r test-requirements.txt && pip install . && SQLALCHEMY_DATABASE_URI=postgresql://postgres@testdb:5432 pytest'
- name: gcr.io/cloud-builders/docker
args: ['stop', 'testdb']
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "$_IMAGE_REPOSITORY:$SHORT_SHA", "-f", "./Dockerfile", "."]
volumes:
- name: "ssh"
path: /root/.ssh
- name: "gcr.io/cloud-builders/docker"
args: ["push", "$_IMAGE_REPOSITORY:$SHORT_SHA"]
timeout: 15m
substitutions:
_IMAGE_REPOSITORY: eu.gcr.io/atlas-275810/mykrobe-atlas-tracking-api
_BITBUCKET_SECRET: ms-bitbucket-readonly
_GITHUB_SECRET: atlas-jsonschema-readonly