-
Notifications
You must be signed in to change notification settings - Fork 14
200 lines (192 loc) · 6.78 KB
/
build-and-deploy.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
name: Build and Deploy
on:
push:
branches: [ master, cicd ]
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'test'
type: choice
options:
- 'test'
- 'production'
branch:
description: 'Branch to deploy'
required: true
default: 'master'
jobs:
build:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.image_tag.outputs.tag }}
strategy:
matrix:
service: [
"datastore",
"docs",
"frontend",
"model-manager",
"model-inference-transformer",
"model-inference-onnx",
"model-inference-sentence-transformer",
"model-inference-graph-transformer",
"skill-manager",
"skill-boolq",
"skill-commonsense-qa",
"skill-extractive-qa",
"skill-generative-qa",
"skill-information-retrieval",
"skill-multiple-choice-qa",
"skill-open-extractive-qa",
"skill-qa-gnn",
"skill-tweac",
"skill-metaqa",
"skill-extractive-metaqa",
"skill-multiple-choice-metaqa",
"skill-kgqa-kqapro",
"evaluator",
"sensitivity",
"replicate",
]
include:
- build-args: ""
- service: datastore
context: ./datastore-api
- service: docs
context: ./docs
- service: frontend
context: ./frontend
build-args: "mode=${{ github.event.inputs.environment || 'test' }}"
- service: model-manager
context: ./model-manager
- service: model-inference-transformer
context: ./model-inference
build-args: "MODEL_TYPE=transformer"
- service: model-inference-onnx
context: ./model-inference
build-args: "MODEL_TYPE=onnx"
- service: model-inference-sentence-transformer
context: ./model-inference
build-args: "MODEL_TYPE=sentence_transformer"
- service: model-inference-graph-transformer
context: ./model-inference
build-args: "MODEL_TYPE=graph_transformer"
- service: skill-manager
context: ./skill-manager
- service: skill-boolq
context: ./skills
build-args: "skill=boolq"
- service: skill-commonsense-qa
context: ./skills
build-args: "skill=commonsense-qa"
- service: skill-extractive-qa
context: ./skills
build-args: "skill=extractive-qa"
- service: skill-generative-qa
context: ./skills
build-args: "skill=generative-qa"
- service: skill-information-retrieval
context: ./skills
build-args: "skill=information-retrieval"
- service: skill-multiple-choice-qa
context: ./skills
build-args: "skill=multiple-choice-qa"
- service: skill-open-extractive-qa
context: ./skills
build-args: "skill=open-extractive-qa"
- service: skill-qa-gnn
context: ./skills
build-args: "skill=qa-gnn"
- service: skill-tweac
context: ./skills
build-args: "skill=tweac"
- service: skill-extractive-metaqa
context: ./skills
build-args: "skill=extractive-metaqa"
- service: skill-multiple-choice-metaqa
context: ./skills
build-args: "skill=multiple-choice-metaqa"
- service: skill-metaqa
context: ./skills
build-args: "skill=metaqa"
- service: "skill-kgqa-kqapro"
context: ./skills
build-args: "skill=kgqa-kqapro"
- service: evaluator
context: ./evaluator
- service: sensitivity
context: ./sensitivity
- service: replicate
context: ./replicate
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.service }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.service }}-
${{ runner.os }}-buildx-
- name: Set Image Tag
id: image_tag
run: |
SHORT_SHA=$(git rev-parse --short ${{ github.sha }})
echo $SHORT_SHA
TAG="${{ github.event.inputs.environment || 'build' }}-$SHORT_SHA"
echo $TAG
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Add latest tag if deploying to prod
uses: haya14busa/action-cond@v1
id: latest_tag_str
with:
cond: ${{ github.event.inputs.environment == 'production' }}
if_true: "ukpsquare/${{matrix.service}}:latest"
if_false: ""
- name: Build deployable image
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{ matrix.context }}
file: ${{ matrix.file }}
target: build
build-args: ${{ matrix.build-args }}
push: ${{ github.event.inputs.environment == 'production' || github.event.inputs.environment == 'test' }}
tags: |
ukpsquare/${{ matrix.service }}:${{ steps.image_tag.outputs.tag }}
${{ steps.latest_tag_str.outputs.value }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy:
needs: build
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- name: Trigger Deployment on ${{ github.event.inputs.environment }}
uses: distributhor/workflow-webhook@v2
env:
webhook_url: ${{ secrets.WEBHOOK_URL }}
webhook_secret: ${{ secrets.WEBHOOK_SECRET }}
data: '{"environment": "${{ github.event.inputs.environment }}", "branch": "${{ github.event.inputs.branch }}", "tag": "${{ needs.build.outputs.tag }}"}'
verify_ssl: false