This repository has been archived by the owner on Dec 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.drone.yml
203 lines (203 loc) · 7.13 KB
/
.drone.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
---
# kind: pipeline
# name: documentation
# steps:
# - name: build-docs
# image: node:alpine
# commands:
# - apk add --no-cache git
# - git config --global user.email "[email protected]"
# - git config --global user.name "Drone.io CI"
# - ./scripts/deploy-documentation.sh
# environment:
# GH_TOKEN:
# from_secret: GH_TOKEN
# GH_USER:
# from_secret: GH_USER
# when:
# branch: master
kind: pipeline
type: docker
name: publish
trigger:
branch:
- master
steps:
- name: build-packages
image: node:alpine
commands:
- apk add --no-cache git
- git config --global user.email "[email protected]"
- git config --global user.name "Drone.io CI"
- yarn install
- yarn run build
- name: publish-npm
when:
event: tag
image: node:alpine
commands:
- echo "bingo"
- name: publish-docker-platyplus
depends_on: [build-packages]
image: plugins/gcr
settings:
dockerfile: backend/platyplus-service/Dockerfile
repo: platyplus-0402/platyplus-service
tags:
- ${DRONE_COMMIT_SHA:0:8}
- ${DRONE_BRANCH}
json_key:
from_secret: google_credentials
- name: publish-docker-graphql-engine
depends_on: [build-packages]
image: plugins/gcr
settings:
dockerfile: backend/graphql-engine/Dockerfile
repo: platyplus-0402/graphql-engine
tags:
- ${DRONE_COMMIT_SHA:0:8}
- ${DRONE_BRANCH}
json_key:
from_secret: google_credentials
- name: publish-docker-authentication
depends_on: [build-packages]
image: plugins/gcr
settings:
dockerfile: backend/authentication-service/Dockerfile
repo: platyplus-0402/authentication-service
tags:
- ${DRONE_COMMIT_SHA:0:8}
- ${DRONE_BRANCH}
json_key:
from_secret: google_credentials
- name: publish-docker-functions
depends_on: [build-packages]
image: plugins/gcr
settings:
dockerfile: backend/functions-service/Dockerfile
repo: platyplus-0402/functions-service
tags:
- ${DRONE_COMMIT_SHA:0:8}
- ${DRONE_BRANCH}
json_key:
from_secret: google_credentials
---
kind: pipeline
type: docker
name: deploy
trigger:
branch:
- master
depends_on: [publish]
steps:
- name: deploy-authentication
image: platyplus/drone-gcloud:latest
environment:
PUBLIC_KEY:
from_secret: PUBLIC_KEY
PRIVATE_KEY:
from_secret: PRIVATE_KEY
HASURA_GRAPHQL_ADMIN_SECRET:
from_secret: HASURA_GRAPHQL_ADMIN_SECRET
settings:
credentials:
from_secret: google_credentials
config:
compute/region: europe-west1
compute/zone: europe-west1-b
run/platform: managed
run/region: europe-west1
commands:
- command: beta run deploy authentication
flags:
- image: gcr.io/platyplus-0402/authentication-service:$${DRONE_COMMIT_SHA:0:8}
- allow-unauthenticated
- timeout: 900
- set-env-vars:
PUBLIC_KEY: '"$$PUBLIC_KEY"'
PRIVATE_KEY: '"$$PRIVATE_KEY"'
HASURA_GRAPHQL_ADMIN_SECRET: '"$$HASURA_GRAPHQL_ADMIN_SECRET"'
- name: deploy-functions
image: platyplus/drone-gcloud:latest
environment:
HASURA_GRAPHQL_ADMIN_SECRET:
from_secret: HASURA_GRAPHQL_ADMIN_SECRET
settings:
credentials:
from_secret: google_credentials
config:
compute/region: europe-west1
compute/zone: europe-west1-b
run/platform: managed
run/region: europe-west1
# ! Set when the functions microservice is ready to work
# - gcloud beta run deploy functions --image gcr.io/platyplus-0402/functions-service:$${DRONE_COMMIT_SHA:0:8} --set-env-vars HASURA_GRAPHQL_ADMIN_SECRET="$$HASURA_GRAPHQL_ADMIN_SECRET"
- name: deploy-graphql-engine
image: platyplus/drone-gcloud:latest
depends_on: [deploy-authentication, deploy-functions]
environment:
HASURA_GRAPHQL_ADMIN_SECRET:
from_secret: HASURA_GRAPHQL_ADMIN_SECRET
POSTGRES_PASSWORD:
from_secret: POSTGRES_PASSWORD
# ! Remove this when functions work
FUNCTIONS_URL: http://functions:3000
settings:
credentials:
from_secret: google_credentials
config:
compute/region: europe-west1
compute/zone: europe-west1-b
run/platform: managed
run/region: europe-west1
commands:
- command: sql databases create hasura-${DRONE_BRANCH} --instance platyplus-main
skipError: true
# gcloud sql users set-password postgres --instance platyplus --password $$POSTGRES_PASSWORD # ? Useless?
- command: sql instances describe platyplus-main --format "get(connectionName)"
export: CLOUDSQL_INSTANCE
- command: beta run services describe authentication --format "get(status.url)"
export: AUTHENTICATION_URL
# ! Set this when functions works
# - export FUNCTIONS_URL="`gcloud beta run services describe functions --format="get(status.url)"`"
- command: beta run deploy graphql-engine
flags:
- image: gcr.io/platyplus-0402/graphql-engine:$${DRONE_COMMIT_SHA:0:8}
- allow-unauthenticated
- timeout: 900
- set-cloudsql-instances: $${CLOUDSQL_INSTANCE}
- set-env-vars:
HASURA_GRAPHQL_DATABASE_URL: '"postgres://postgres:$${POSTGRES_PASSWORD}@/hasura-${DRONE_BRANCH}?host=/cloudsql/$${CLOUDSQL_INSTANCE}"'
AUTHENTICATION_URL: '"$$AUTHENTICATION_URL"'
FUNCTIONS_URL: '"$$FUNCTIONS_URL"'
HASURA_GRAPHQL_ADMIN_SECRET: '"$$HASURA_GRAPHQL_ADMIN_SECRET"'
# ENABLE_CLOUDSQL_PROXY: '"true"'
# * The following services need to have the graphql-engine to send him requests, but graphql-engine needed them first
- command: beta run services describe graphql-engine --format="get(status.url)"
export: GRAPHQL_ENGINE_URL
- beta run services update authentication --update-env-vars GRAPHQL_ENGINE_URL="$$GRAPHQL_ENGINE_URL"
# ! Set the following line when the functions microservice is ready to work
# - gcloud beta run services update functions --update-env-vars GRAPHQL_ENGINE_URL="$$GRAPHQL_ENGINE_URL"
- name: deploy-platyplus
image: platyplus/drone-gcloud:latest
depends_on: [deploy-graphql-engine]
settings:
credentials:
from_secret: google_credentials
config:
compute/region: europe-west1
compute/zone: europe-west1-b
run/platform: managed
run/region: europe-west1
commands:
- command: beta run services describe graphql-engine --format="get(status.url)"
export: GRAPHQL_ENGINE_PUBLIC_URL
- command: beta run deploy platyplus
flags:
- image: gcr.io/platyplus-0402/platyplus-service:$${DRONE_COMMIT_SHA:0:8}
- allow-unauthenticated
- timeout: 900
- update-env-vars: GRAPHQL_ENGINE_PUBLIC_URL="$$GRAPHQL_ENGINE_PUBLIC_URL"
---
kind: signature
hmac: d9887fbf0d90e9d111f8680076a834749a9a94861a641abe853e9e686265b321