-
Notifications
You must be signed in to change notification settings - Fork 2
307 lines (285 loc) · 11.2 KB
/
Copy pathunified-ci.yml
File metadata and controls
307 lines (285 loc) · 11.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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2025-Present Datadog, Inc.
name: Unified CI/CD
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
inputs:
deploy:
description: 'Deploy to AWS dev environment after build'
required: false
default: false
type: boolean
force-all:
description: 'Force build all services regardless of changes'
required: false
default: false
type: boolean
env:
REGISTRY: ghcr.io
REPOSITORY_URL: github.com/${{ github.repository }}
jobs:
# ============================================================================
# CHANGE DETECTION
# ============================================================================
detect-changes:
runs-on: ubuntu-latest
outputs:
user-management: ${{ steps.filter.outputs.user-management }}
sticker-award: ${{ steps.filter.outputs.sticker-award }}
sticker-catalogue: ${{ steps.filter.outputs.sticker-catalogue }}
web-backend: ${{ steps.filter.outputs.web-backend }}
web-frontend: ${{ steps.filter.outputs.web-frontend }}
shared: ${{ steps.filter.outputs.shared }}
any-service: ${{ steps.filter.outputs.user-management == 'true' || steps.filter.outputs.sticker-award == 'true' || steps.filter.outputs.sticker-catalogue == 'true' || steps.filter.outputs.web-backend == 'true' || steps.filter.outputs.web-frontend == 'true' }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Detect changed paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
user-management:
- 'user-management/**'
sticker-award:
- 'sticker-award/**'
sticker-catalogue:
- 'sticker-catalogue/**'
web-backend:
- 'web-backend/**'
web-frontend:
- 'web-frontend/**'
shared:
- 'shared/**'
workflows:
- '.github/**'
# ============================================================================
# USER MANAGEMENT SERVICE (.NET)
# ============================================================================
user-management-build:
needs: detect-changes
if: |
true || # TEMPORARY: Remove after testing
github.event.inputs.force-all == 'true' ||
github.event_name == 'push' ||
needs.detect-changes.outputs.user-management == 'true' ||
needs.detect-changes.outputs.shared == 'true'
uses: ./.github/workflows/_build-dotnet.yml
with:
working-directory: user-management
dotnet-version: '10.0.x'
user-management-push-api:
needs: user-management-build
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_push-images.yml
with:
image-name: user-management-service
context: ./user-management
dockerfile: ./user-management/src/Stickerlandia.UserManagement.Api/Dockerfile
user-management-push-worker:
needs: user-management-build
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_push-images.yml
with:
image-name: user-management-worker
context: ./user-management
dockerfile: ./user-management/src/Stickerlandia.UserManagement.Worker/Dockerfile
user-management-push-migration:
needs: user-management-build
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_push-images.yml
with:
image-name: user-management-migration
context: ./user-management
dockerfile: ./user-management/src/Stickerlandia.UserManagement.MigrationService/Dockerfile
user-management-deploy:
needs: [user-management-push-api, user-management-push-worker, user-management-push-migration]
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_deploy-aws.yml
with:
service-name: user-management
infra-directory: user-management/infra/aws
dotnet-version: '10.0.x'
secrets:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
# ============================================================================
# STICKER AWARD SERVICE (Go)
# ============================================================================
sticker-award-build:
needs: detect-changes
if: |
true || # TEMPORARY: Remove after testing
github.event.inputs.force-all == 'true' ||
github.event_name == 'push' ||
needs.detect-changes.outputs.sticker-award == 'true' ||
needs.detect-changes.outputs.shared == 'true'
uses: ./.github/workflows/_build-go.yml
with:
working-directory: sticker-award
go-version: '1.21'
sticker-award-push:
needs: sticker-award-build
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_push-images.yml
with:
image-name: sticker-award-service
context: ./sticker-award
dockerfile: ./sticker-award/Dockerfile
go-version: '1.21'
sticker-award-deploy:
needs: sticker-award-push
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_deploy-aws.yml
with:
service-name: sticker-award
infra-directory: sticker-award/infra/aws
go-version: '1.21'
secrets:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
# ============================================================================
# STICKER CATALOGUE SERVICE (Java)
# ============================================================================
sticker-catalogue-build:
needs: detect-changes
if: |
true || # TEMPORARY: Remove after testing
github.event.inputs.force-all == 'true' ||
github.event_name == 'push' ||
needs.detect-changes.outputs.sticker-catalogue == 'true' ||
needs.detect-changes.outputs.shared == 'true'
uses: ./.github/workflows/_build-java.yml
with:
working-directory: sticker-catalogue
java-version: '21'
sticker-catalogue-push:
needs: sticker-catalogue-build
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_push-images.yml
with:
image-name: sticker-catalogue-service
context: ./sticker-catalogue
dockerfile: ./sticker-catalogue/src/main/docker/Dockerfile.jvm
java-version: '21'
pre-build-command: 'cd sticker-catalogue && ./mvnw package -DskipTests'
sticker-catalogue-deploy:
needs: sticker-catalogue-push
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_deploy-aws.yml
with:
service-name: sticker-catalogue
infra-directory: sticker-catalogue/infra/aws
java-version: '21'
secrets:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
# ============================================================================
# WEB BACKEND SERVICE (Node.js)
# ============================================================================
web-backend-build:
needs: detect-changes
if: |
true || # TEMPORARY: Remove after testing
github.event.inputs.force-all == 'true' ||
github.event_name == 'push' ||
needs.detect-changes.outputs.web-backend == 'true' ||
needs.detect-changes.outputs.shared == 'true'
uses: ./.github/workflows/_build-node.yml
with:
working-directory: web-backend
node-version: '18'
web-backend-push:
needs: web-backend-build
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_push-images.yml
with:
image-name: web-backend-service
context: ./web-backend
dockerfile: ./web-backend/Dockerfile
web-backend-deploy:
needs: web-backend-push
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_deploy-aws.yml
with:
service-name: web-backend
infra-directory: web-backend/infra/aws
node-version: '18'
secrets:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
# ============================================================================
# WEB FRONTEND SERVICE (React/Node.js)
# ============================================================================
web-frontend-push:
needs: detect-changes
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_push-images.yml
with:
image-name: web-frontend
context: ./web-frontend
dockerfile: ./web-frontend/Dockerfile
web-frontend-deploy:
needs: web-frontend-push
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.deploy == true)
uses: ./.github/workflows/_deploy-aws.yml
with:
service-name: web-frontend
infra-directory: web-frontend/infra/aws
node-version: '18'
pre-deploy-command: 'cd web-frontend && npm install && npm run build'
secrets:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
# ============================================================================
# FAN-IN: UI/E2E TESTS (runs after all deployments complete)
# ============================================================================
ui-tests:
needs:
- user-management-deploy
- sticker-award-deploy
- sticker-catalogue-deploy
- web-backend-deploy
- web-frontend-deploy
# Run if:
# - We're on main branch push AND
# - All preceding jobs either succeeded or were skipped (not failed/cancelled)
if: |
always() &&
github.event_name == 'push' &&
github.ref == 'refs/heads/main' &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/_ui-tests.yml
with:
environment: dev
secrets:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}