-
Notifications
You must be signed in to change notification settings - Fork 10
284 lines (277 loc) · 9.05 KB
/
build.yaml
File metadata and controls
284 lines (277 loc) · 9.05 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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# this is a reusable workflow to build and deploy the crypt
# it is called by other workflows
on:
workflow_call:
inputs:
DEPLOYMENT_CHAIN:
type: string
description: anvil,redstone etc
default: anvil
DEPLOYMENT_ENVIRONMENT:
description: Name of environment main/prod/test to deploy to
required: true
type: string
DEPLOYMENT_PRIORITY:
description: priorityClassName for pods
required: true
type: string
DEPLOYMENT_DOMAIN:
description: externaldns name
required: true
type: string
PLATFORMS:
description: platforms for multiarch images
required: true
default: linux/arm64/v8,linux/amd64
type: string
RUN_DEPLOY:
description: Flag to control whether to run the deploy job or not
required: false
default: true
type: boolean
secrets:
AZURE_REGISTRY_URL:
description: Docker login url for Azure Container Registry
required: true
AZURE_REGISTRY_USERNAME:
description: Docker login username for Azure Container Registry
required: true
AZURE_REGISTRY_PASSWORD:
description: Docker login password for Azure Container Registry
required: true
AZURE_CREDENTIALS:
description: Azure credentials for deploying to Azure Container Service
required: true
AZURE_CLUSTER_NAME:
description: Name of the Azure Container Service cluster
required: true
AZURE_CLUSTER_RESOURCE_GROUP:
description: Name of the resource group where the cluster lives
required: true
UNITY_SERIAL:
description: Unity licence serial
required: true
UNITY_EMAIL:
description: Unity email for licence
required: true
UNITY_PASSWORD:
description: Unity password for the licence
required: true
env:
REGISTRY: ghcr.io
FRONTEND_IMAGE_NAME: playmint/ds-shell
CONTRACTS_IMAGE_NAME: playmint/ds-contracts
SERVICES_IMAGE_NAME: playmint/ds-services
jobs:
frontend:
name: Frontend
runs-on: ubuntu-latest-m
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Create LFS file list
run: git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v2
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: |
git lfs pull
- name: Restore Library cache
uses: actions/cache@v2
with:
path: map/Library
key: Library-ds
restore-keys: |
Library-ds
Library-
- name: Build ds
uses: game-ci/unity-builder@v2
env:
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
targetPlatform: WebGL
projectPath: map
buildMethod: BuildScript.GitHubBuild
allowDirtyBuild: true # allows for use of LFS cache
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: "arm64,arm"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: frontend/Dockerfile
push: true
tags: |
"${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:${{ github.sha }}"
"${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:${{ inputs.DEPLOYMENT_ENVIRONMENT }}"
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ inputs.PLATFORMS }}
contracts:
name: Contracts
runs-on: ubuntu-latest-m
permissions:
id-token: write
packages: write
contents: read
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: "arm64,arm"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: contracts/Dockerfile
push: true
tags: |
"${{ env.REGISTRY }}/${{ env.CONTRACTS_IMAGE_NAME }}:${{ github.sha }}"
"${{ env.REGISTRY }}/${{ env.CONTRACTS_IMAGE_NAME }}:${{ inputs.DEPLOYMENT_ENVIRONMENT }}"
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ inputs.PLATFORMS }}
services:
name: Services
runs-on: ubuntu-latest-m
permissions:
id-token: write
packages: write
contents: read
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: "arm64,arm"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: contracts/lib/cog/services
push: true
tags: |
"${{ env.REGISTRY }}/${{ env.SERVICES_IMAGE_NAME }}:${{ github.sha }}"
"${{ env.REGISTRY }}/${{ env.SERVICES_IMAGE_NAME }}:${{ inputs.DEPLOYMENT_ENVIRONMENT }}"
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ inputs.PLATFORMS }}
deploy:
name: Deploy
runs-on: ubuntu-latest-m
if: ${{ inputs.RUN_DEPLOY }}
needs:
- frontend
- contracts
- services
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: "18.x"
- name: Update deployment status
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ inputs.DEPLOYMENT_ENVIRONMENT }}
ref: ${{ github.head_ref }}
- name: Authenticate to Azure Container Service
uses: azure/aks-set-context@v1
with:
creds: "${{ secrets.AZURE_CREDENTIALS }}"
cluster-name: ${{ secrets.AZURE_CLUSTER_NAME }}
resource-group: ${{ secrets.AZURE_CLUSTER_RESOURCE_GROUP }}
- name: Prepare helm
uses: azure/setup-helm@v3
with:
version: "3.7.2"
- name: Deploy to Azure
env:
CHART_VERSION: ${{ github.sha }}
CHART_NAMESPACE: ${{ inputs.DEPLOYMENT_ENVIRONMENT }}
CHART_VALUES: |-
chain: ${{ inputs.DEPLOYMENT_CHAIN }}
cluster:
domain: ${{ inputs.DEPLOYMENT_DOMAIN }}
version: ${{ github.sha }}
priorityClassName: ${{ inputs.DEPLOYMENT_PRIORITY }}
run: |
echo "${CHART_VALUES}" > /tmp/values.yaml
helm upgrade --install --wait \
--timeout "30m" \
--history-max 5 \
ds ./chart \
--values /tmp/values.yaml \
--create-namespace \
-n "${CHART_NAMESPACE}"
- name: Wait for services
uses: iFaxity/[email protected]
with:
resource: https://services-${{ inputs.DEPLOYMENT_ENVIRONMENT }}.${{ inputs.DEPLOYMENT_DOMAIN }}/
interval: 1000
simultaneous: 1
timeout: 600000
- name: Update deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
env_url: https://${{ inputs.DEPLOYMENT_ENVIRONMENT }}.${{ inputs.DEPLOYMENT_DOMAIN }}/
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}