Skip to content

Commit c2d9b4a

Browse files
committed
docs: use valid cdevents samples in the doc
1 parent f7e3c1e commit c2d9b4a

File tree

2 files changed

+88
-5
lines changed

2 files changed

+88
-5
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99

1010
env:
11-
VALID_CDEVENT: '{"context":{"version":"0.3.0","id":"test-${{ github.run_id }}","source":"github-action-test","type":"dev.cdevents.build.started.0.1.1","timestamp":"2024-01-01T00:00:00Z"},"subject":{"id":"test-subject","source":"https://github.com/test/repo"}}'
11+
VALID_CDEVENT: '{"context":{"version":"0.4.1","source":"github-action-test","type":"dev.cdevents.taskrun.started.0.2.0"},"subject":{"id":"test-task-${{ github.run_id }}","source":"github-action-test","type":"taskRun","content":{"taskName":"ci-test","url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}}}'
1212
INVALID_CDEVENT: '{"invalid": "missing required fields"}'
1313

1414
jobs:

README.md

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@ jobs:
1919
- name: Send CDEvent
2020
uses: cdviz-dev/send-cdevents@v1
2121
with:
22-
data: '{"type": "dev.cdevents.build.started.0.1.1", "source": "github-action"}'
22+
data: |
23+
{
24+
"context": {
25+
"version": "0.4.1",
26+
"source": "github-actions",
27+
"type": "dev.cdevents.taskrun.started.0.2.0"
28+
},
29+
"subject": {
30+
"id": "${{ github.run_id }}",
31+
"type": "taskRun",
32+
"content": {
33+
"taskName": "ci-build"
34+
}
35+
}
36+
}
2337
url: "https://your-webhook-endpoint.com/cdevents"
2438
```
2539
@@ -38,7 +52,23 @@ jobs:
3852
- name: Send CDEvent
3953
uses: cdviz-dev/send-cdevents@v1
4054
with:
41-
data: '{"type": "dev.cdevents.build.started.0.1.1", "source": "github-action"}'
55+
data: |
56+
{
57+
"context": {
58+
"version": "0.4.1",
59+
"source": "github-actions",
60+
"type": "dev.cdevents.service.deployed.0.2.0"
61+
},
62+
"subject": {
63+
"id": "${{ github.repository }}",
64+
"type": "service",
65+
"content": {
66+
"environment": {
67+
"id": "production"
68+
}
69+
}
70+
}
71+
}
4272
url: "https://your-webhook-endpoint.com/cdevents"
4373
headers: |
4474
Authorization: Bearer ${{ secrets.API_TOKEN }}
@@ -60,7 +90,24 @@ jobs:
6090
- name: Send CDEvent with HMAC signature
6191
uses: cdviz-dev/send-cdevents@v1
6292
with:
63-
data: '{"type": "dev.cdevents.build.started.0.1.1", "source": "github-action"}'
93+
data: |
94+
{
95+
"context": {
96+
"version": "0.4.1",
97+
"source": "github-actions",
98+
"type": "dev.cdevents.testcaserun.started.0.2.0"
99+
},
100+
"subject": {
101+
"id": "${{ github.run_id }}-test",
102+
"type": "testCaseRun",
103+
"content": {
104+
"testCase": {
105+
"name": "Integration Tests",
106+
"type": "integration"
107+
}
108+
}
109+
}
110+
}
64111
url: "https://your-webhook-endpoint.com/cdevents"
65112
config: |
66113
[sinks.http.headers.x-signature-256]
@@ -150,9 +197,45 @@ Examples:
150197

151198
```yaml
152199
with:
153-
data: '{"type": "dev.cdevents.build.started.0.1.1", "source": "github-action"}'
200+
data: |
201+
{
202+
"context": {
203+
"version": "0.4.1",
204+
"source": "github-actions",
205+
"type": "dev.cdevents.taskrun.started.0.2.0"
206+
},
207+
"subject": {
208+
"id": "${{ github.run_id }}",
209+
"type": "taskRun",
210+
"content": {
211+
"taskName": "ci-build"
212+
}
213+
}
214+
}
154215
```
155216

217+
> [!TIP]
218+
> The `context.id` and `context.timestamp` fields can be automatically generated by cdviz-collector if missing from your CDEvent. You can provide minimal CDEvents and let the collector handle the required metadata:
219+
>
220+
> ```yaml
221+
> with:
222+
> data: |
223+
> {
224+
> "context": {
225+
> "version": "0.4.1",
226+
> "source": "github-actions",
227+
> "type": "dev.cdevents.taskrun.started.0.2.0"
228+
> },
229+
> "subject": {
230+
> "id": "${{ github.run_id }}",
231+
> "type": "taskRun",
232+
> "content": {
233+
> "taskName": "ci-build"
234+
> }
235+
> }
236+
> }
237+
> ```
238+
156239
### From File
157240

158241
```yaml

0 commit comments

Comments
 (0)