-
Notifications
You must be signed in to change notification settings - Fork 44
285 lines (254 loc) · 10.2 KB
/
offline.yml
File metadata and controls
285 lines (254 loc) · 10.2 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
285
# Offline Build Workflow
#
# This workflow builds offline deployment artifacts for different profiles:
# - default: Production deployment (includes external charts, ansible, terraform)
# - build-wiab-staging: Wire-in-a-box (wiab-stag) a production like deployment (includes external charts, ansible, terraform)
# - wiab-dev: Wire-in-a-box dev deployment (includes databases-ephemeral)
# - min: Minimal deployment
#
# Build Optimization via PR Labels:
# - No label: No builds run (must add label to trigger builds)
# - 'build-default': Builds only default profile
# - 'build-dev': Builds only demo profile
# - 'build-wiab-staging' - Builds only wiab-staging profile
# - 'build-min': Builds only min profile
# - 'build-all': Explicitly builds all profiles (useful for workflow changes)
#
# Push to master/develop: Always builds all profiles regardless of labels
#
on:
push:
branches: ["**"]
tags: [v*]
paths-ignore:
- "*.md"
- "**/*.md"
pull_request:
types: [synchronize, reopened, labeled]
branches: ["**"]
paths-ignore:
- "*.md"
- "**/*.md"
jobs:
# Build default profile and create local assets
build-default:
name: Build default profile
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
contains(github.event.pull_request.labels.*.name, 'build-all') ||
contains(github.event.pull_request.labels.*.name, 'build-default') ||
contains(github.event.pull_request.labels.*.name, 'build-wiab-staging')
runs-on:
group: wire-server-deploy
outputs:
upload_name: ${{ steps.upload_name.outputs.UPLOAD_NAME }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: cachix/install-nix-action@v27
- uses: cachix/cachix-action@v15
with:
name: wire-server
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: Install nix environment
run: nix-env -f default.nix -iA env
- name: Get upload name
id: upload_name
run: echo "UPLOAD_NAME=$GITHUB_SHA" >> $GITHUB_OUTPUT
# default profile build
- name: Process the default profile build
run: ./offline/default-build/build.sh
env:
GPG_PRIVATE_KEY: '${{ secrets.GPG_PRIVATE_KEY }}'
DOCKER_LOGIN: '${{ secrets.DOCKER_LOGIN }}'
- name: Copy default build assets tarball to S3
run: |
aws s3 cp offline/default-build/output/assets.tgz s3://public.wire.com/artifacts/wire-server-deploy-static-${{ steps.upload_name.outputs.UPLOAD_NAME }}.tgz
echo "Uploaded to: https://s3-$AWS_REGION.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-${{ steps.upload_name.outputs.UPLOAD_NAME }}.tgz"
env:
AWS_ACCESS_KEY_ID: '${{ secrets.AWS_ACCESS_KEY_ID }}'
AWS_SECRET_ACCESS_KEY: '${{ secrets.AWS_SECRET_ACCESS_KEY }}'
AWS_REGION: "eu-west-1"
verify-default:
name: Verify default profile
needs: build-default
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
contains(github.event.pull_request.labels.*.name, 'build-all') ||
contains(github.event.pull_request.labels.*.name, 'build-default')
runs-on:
group: wire-server-deploy
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: cachix/install-nix-action@v27
- uses: cachix/cachix-action@v15
with:
name: wire-server
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: Install nix environment
run: nix-env -f default.nix -iA env
- name: Install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "^1.3.7"
terraform_wrapper: false
- name: Deploy offline environment to hetzner
run: ./offline/cd.sh
env:
HCLOUD_TOKEN: '${{ secrets.HCLOUD_TOKEN }}'
- name: Clean up hetzner environment; just in case
if: always()
run: (cd terraform/examples/wire-server-deploy-offline-hetzner ; terraform init && terraform destroy -auto-approve)
env:
HCLOUD_TOKEN: '${{ secrets.HCLOUD_TOKEN }}'
# verify wiab-staging profile
verify-wiab-staging:
name: Verify wiab staging profile
needs: build-default
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
contains(github.event.pull_request.labels.*.name, 'build-all') ||
contains(github.event.pull_request.labels.*.name, 'build-wiab-staging')
runs-on:
group: wire-server-deploy
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: cachix/install-nix-action@v27
- uses: cachix/cachix-action@v15
with:
name: wire-server
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: Install nix environment
run: nix-env -f default.nix -iA env
- name: Install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "^1.3.7"
terraform_wrapper: false
- name: Deploy offline wiab-staging environment to hetzner
run: ./offline/cd_staging.sh
env:
HCLOUD_TOKEN: '${{ secrets.HCLOUD_TOKEN }}'
- name: Clean up hetzner wiab-staging environment; just in case
if: always()
run: (cd terraform/examples/wiab-staging-hetzner ; terraform init && terraform destroy -auto-approve)
env:
HCLOUD_TOKEN: '${{ secrets.HCLOUD_TOKEN }}'
# Build container in parallel
build-container:
name: Build container
needs: build-default
runs-on:
group: wire-server-deploy
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: cachix/install-nix-action@v27
- uses: cachix/cachix-action@v15
with:
name: wire-server
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: Build and upload wire-server-deploy container
run: |
container_image=$(nix-build --no-out-link -A container)
skopeo copy --retry-times 10 --dest-creds "$DOCKER_LOGIN" \
docker-archive:"$container_image" \
"docker://quay.io/wire/wire-server-deploy:${{ needs.build-default.outputs.upload_name }}"
env:
DOCKER_LOGIN: '${{ secrets.DOCKER_LOGIN }}'
# Build dev profile
build-dev:
name: Build dev profile
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
contains(github.event.pull_request.labels.*.name, 'build-all') ||
contains(github.event.pull_request.labels.*.name, 'build-dev')
runs-on:
group: wire-server-deploy
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: cachix/install-nix-action@v27
- uses: cachix/cachix-action@v15
with:
name: wire-server
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: Install nix environment
run: nix-env -f default.nix -iA env
- name: Get upload name
id: upload_name
run: echo "UPLOAD_NAME=$GITHUB_SHA" >> $GITHUB_OUTPUT
- name: Process the dev profile build
run: ./offline/demo-build/build.sh
env:
GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}"
DOCKER_LOGIN: "${{ secrets.DOCKER_LOGIN }}"
- name: Copy dev build assets tarball to S3
run: |
aws s3 cp offline/demo-build/output/assets.tgz s3://public.wire.com/artifacts/wire-server-deploy-static-demo-${{ steps.upload_name.outputs.UPLOAD_NAME }}.tgz
echo "Uploaded to: https://s3-$AWS_REGION.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-demo-${{ steps.upload_name.outputs.UPLOAD_NAME }}.tgz"
env:
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
AWS_REGION: "eu-west-1"
- name: Install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "^1.3.7"
terraform_wrapper: false
- name: Deploy offline demo-wiab environment to hetzner
run: ./offline/cd_demo.sh
env:
HCLOUD_TOKEN: '${{ secrets.HCLOUD_TOKEN }}'
- name: Clean up hetzner wiab environment; just in case
if: always()
run: (cd terraform/examples/wiab-demo-hetzner ; terraform init && terraform destroy -auto-approve)
env:
HCLOUD_TOKEN: '${{ secrets.HCLOUD_TOKEN }}'
- name: Cleanup dev build assets
run: rm -rf offline/demo-build/output/
# Build min profile
build-min:
name: Build min profile
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
contains(github.event.pull_request.labels.*.name, 'build-all') ||
contains(github.event.pull_request.labels.*.name, 'build-min')
runs-on:
group: wire-server-deploy
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: cachix/install-nix-action@v27
- uses: cachix/cachix-action@v15
with:
name: wire-server
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: Install nix environment
run: nix-env -f default.nix -iA env
- name: Get upload name
id: upload_name
run: echo "UPLOAD_NAME=$GITHUB_SHA" >> $GITHUB_OUTPUT
- name: Process the min profile build
run: ./offline/min-build/build.sh
env:
GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}"
DOCKER_LOGIN: "${{ secrets.DOCKER_LOGIN }}"
- name: Copy min build assets tarball to S3
run: |
aws s3 cp offline/min-build/output/assets.tgz s3://public.wire.com/artifacts/wire-server-deploy-static-min-${{ steps.upload_name.outputs.UPLOAD_NAME }}.tgz
echo "Uploaded to: https://s3-$AWS_REGION.amazonaws.com/public.wire.com/artifacts/wire-server-deploy-static-min-${{ steps.upload_name.outputs.UPLOAD_NAME }}.tgz"
env:
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
AWS_REGION: "eu-west-1"
- name: Cleanup min build assets
run: rm -rf offline/min-build/output/