@@ -26,24 +26,26 @@ jobs:
26
26
datadog-ci :
27
27
runs-on : ubuntu-latest
28
28
steps :
29
- - name : Setup Datadog CI
30
- id : datadog-setup
31
- uses : DataDog/github-action-dd-trace@v1
32
- with :
33
- api-key : ${{ secrets.DATADOG_API_KEY }}
34
- site : datadoghq.com
35
- service : lace-wallet
36
- env : ci
37
- tags : ci:true,service:lace-wallet,repo:lace
38
-
39
29
- name : Send CI metrics to Datadog
40
- uses : DataDog/github-action-metrics@v1
41
- with :
42
- api-key : ${{ secrets.DATADOG_API_KEY }}
43
- site : datadoghq.com
44
- metrics : |
45
- github.ci.pipeline.duration:${{ github.run_duration }}|#service:lace-wallet,env:ci,workflow:${{ github.workflow }},job:${{ github.job }}
46
- github.ci.pipeline.status:1|#service:lace-wallet,env:ci,workflow:${{ github.workflow }},job:${{ github.job }},status:${{ job.status }}
30
+ run : |
31
+ if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
32
+ curl -X POST "https://api.datadoghq.com/api/v1/series" \
33
+ -H "Content-Type: application/json" \
34
+ -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
35
+ -d '{
36
+ "series": [{
37
+ "metric": "github.ci.pipeline.duration",
38
+ "points": [[$(date +%s), ${{ github.run_duration }}]],
39
+ "tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}"],
40
+ "type": "gauge"
41
+ }, {
42
+ "metric": "github.ci.pipeline.status",
43
+ "points": [[$(date +%s), 1]],
44
+ "tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}", "status:${{ job.status }}"],
45
+ "type": "gauge"
46
+ }]
47
+ }'
48
+ fi
47
49
48
50
prepare :
49
51
name : Prepare
@@ -111,17 +113,19 @@ jobs:
111
113
112
114
- name : Send build metrics to Datadog
113
115
run : |
114
- curl -X POST "https://api.datadoghq.com/api/v1/series" \
115
- -H "Content-Type: application/json" \
116
- -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
117
- -d '{
118
- "series": [{
119
- "metric": "lace.build.packages",
120
- "points": [[$(date +%s), 7]],
121
- "tags": ["service:lace-wallet", "env:ci", "workflow:prepare"],
122
- "type": "gauge"
123
- }]
124
- }'
116
+ if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
117
+ curl -X POST "https://api.datadoghq.com/api/v1/series" \
118
+ -H "Content-Type: application/json" \
119
+ -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
120
+ -d '{
121
+ "series": [{
122
+ "metric": "lace.build.packages",
123
+ "points": [[$(date +%s), 7]],
124
+ "tags": ["service:lace-wallet", "env:ci", "workflow:prepare"],
125
+ "type": "gauge"
126
+ }]
127
+ }'
128
+ fi
125
129
126
130
unitTests :
127
131
name : Unit tests
@@ -190,17 +194,19 @@ jobs:
190
194
191
195
- name : Send test metrics to Datadog
192
196
run : |
193
- curl -X POST "https://api.datadoghq.com/api/v1/series" \
194
- -H "Content-Type: application/json" \
195
- -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
196
- -d '{
197
- "series": [{
198
- "metric": "lace.tests.unit",
199
- "points": [[$(date +%s), 1]],
200
- "tags": ["service:lace-wallet", "env:ci", "workflow:unitTests", "status:${{ job.status }}"],
201
- "type": "gauge"
202
- }]
203
- }'
197
+ if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
198
+ curl -X POST "https://api.datadoghq.com/api/v1/series" \
199
+ -H "Content-Type: application/json" \
200
+ -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
201
+ -d '{
202
+ "series": [{
203
+ "metric": "lace.tests.unit",
204
+ "points": [[$(date +%s), 1]],
205
+ "tags": ["service:lace-wallet", "env:ci", "workflow:unitTests", "status:${{ job.status }}"],
206
+ "type": "gauge"
207
+ }]
208
+ }'
209
+ fi
204
210
205
211
release-pkg :
206
212
name : Release package
@@ -269,31 +275,35 @@ jobs:
269
275
270
276
- name : Send release metrics to Datadog
271
277
run : |
272
- curl -X POST "https://api.datadoghq.com/api/v1/series" \
273
- -H "Content-Type: application/json" \
274
- -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
275
- -d '{
276
- "series": [{
277
- "metric": "lace.release.package",
278
- "points": [[$(date +%s), 1]],
279
- "tags": ["service:lace-wallet", "env:ci", "workflow:release-pkg", "status:${{ job.status }}"],
280
- "type": "gauge"
281
- }]
282
- }'
278
+ if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
279
+ curl -X POST "https://api.datadoghq.com/api/v1/series" \
280
+ -H "Content-Type: application/json" \
281
+ -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
282
+ -d '{
283
+ "series": [{
284
+ "metric": "lace.release.package",
285
+ "points": [[$(date +%s), 1]],
286
+ "tags": ["service:lace-wallet", "env:ci", "workflow:release-pkg", "status:${{ job.status }}"],
287
+ "type": "gauge"
288
+ }]
289
+ }'
290
+ fi
283
291
284
292
datadog-final :
285
293
needs : [prepare, unitTests, release-pkg]
286
294
runs-on : ubuntu-latest
287
295
steps :
288
296
- name : Send final CI metrics to Datadog
289
297
run : |
290
- curl -X POST "https://api.datadoghq.com/api/v1/events" \
291
- -H "Content-Type: application/json" \
292
- -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
293
- -d '{
294
- "title": "Lace CI Pipeline Complete",
295
- "text": "All CI jobs completed for ${{ github.repository }}\nBranch: ${{ github.ref_name }}\nCommit: ${{ github.sha }}\nStatus: ${{ needs.prepare.result }}, ${{ needs.unitTests.result }}, ${{ needs.release-pkg.result }}",
296
- "tags": ["service:lace-wallet", "env:ci", "workflow:ci", "repo:lace"],
297
- "alert_type": "${{ needs.prepare.result == 'success' && needs.unitTests.result == 'success' && needs.release-pkg.result == 'success' && 'info' || 'error' }}",
298
- "source_type_name": "github"
299
- }'
298
+ if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
299
+ curl -X POST "https://api.datadoghq.com/api/v1/events" \
300
+ -H "Content-Type: application/json" \
301
+ -H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
302
+ -d '{
303
+ "title": "Lace CI Pipeline Complete",
304
+ "text": "All CI jobs completed for ${{ github.repository }}\nBranch: ${{ github.ref_name }}\nCommit: ${{ github.sha }}\nStatus: ${{ needs.prepare.result }}, ${{ needs.unitTests.result }}, ${{ needs.release-pkg.result }}",
305
+ "tags": ["service:lace-wallet", "env:ci", "workflow:ci", "repo:lace"],
306
+ "alert_type": "${{ needs.prepare.result == 'success' && needs.unitTests.result == 'success' && needs.release-pkg.result == 'success' && 'info' || 'error' }}",
307
+ "source_type_name": "github"
308
+ }'
309
+ fi
0 commit comments