A GitHub Action that sends CDEvents using the cdviz-collector send subcommand.
name: Send CDEventon:
push:
branches: [main]jobs:
send-event:
runs-on: ubuntu-lateststeps:
- name: Send CDEventuses: cdviz-dev/send-cdevents@v1with:
data: | { "context": { "version": "0.4.1", "source": "github-actions", "type": "dev.cdevents.taskrun.started.0.2.0" }, "subject": { "id": "${{ github.run_id }}", "type": "taskRun", "content": { "taskName": "ci-build" } } }url: "https://your-webhook-endpoint.com/cdevents"name: Send CDEvent with Authenticationon:
push:
branches: [main]jobs:
send-event:
runs-on: ubuntu-lateststeps:
- name: Send CDEventuses: cdviz-dev/send-cdevents@v1with:
data: | { "context": { "version": "0.4.1", "source": "github-actions", "type": "dev.cdevents.service.deployed.0.2.0" }, "subject": { "id": "${{ github.repository }}", "type": "service", "content": { "environment": { "id": "production" } } } }url: "https://your-webhook-endpoint.com/cdevents"headers: | Authorization: Bearer ${{ secrets.API_TOKEN }} X-Source: GitHubname: Send CDEvent with Configon:
push:
branches: [main]jobs:
send-event:
runs-on: ubuntu-lateststeps:
- name: Send CDEvent with HMAC signatureuses: cdviz-dev/send-cdevents@v1with:
data: | { "context": { "version": "0.4.1", "source": "github-actions", "type": "dev.cdevents.testcaserun.started.0.2.0" }, "subject": { "id": "${{ github.run_id }}-test", "type": "testCaseRun", "content": { "testCase": { "name": "Integration Tests", "type": "integration" } } } }url: "https://your-webhook-endpoint.com/cdevents"config: | [sinks.http.headers.x-signature-256] type = "signature" token = "${{ secrets.WEBHOOK_SECRET }}" algorithm = "sha256" prefix = "sha256="name: Send CDEvent with Environment Variableson:
push:
branches: [main]jobs:
send-event:
runs-on: ubuntu-lateststeps:
- name: Send CDEvent with env varsuses: cdviz-dev/send-cdevents@v1env:
CDVIZ_COLLECTOR__SINKS__HTTP__HEADERS__X_SIGNATURE_256__TOKEN: ${{ secrets.WEBHOOK_SECRET }}with:
data: '{"type": "dev.cdevents.build.started.0.1.1", "source": "github-action"}'url: "https://your-webhook-endpoint.com/cdevents"config: | [sinks.http.headers.x-signature-256] type = "signature" algorithm = "sha256" prefix = "sha256="name: Send CDEvent from Fileon:
push:
branches: [main]jobs:
send-event:
runs-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@v4
- name: Send CDEventuses: cdviz-dev/send-cdevents@v1with:
data: "@.github/cdevents/build-started.json"url: "https://your-webhook-endpoint.com/cdevents"| Input | Description | Required | Default |
|---|---|---|---|
data | JSON data to send. Can be direct JSON string, file path (@file.json), or stdin (@-) | Yes | - |
url | HTTP URL to send the data to. When specified, automatically enables the HTTP sink | No | - |
config | TOML configuration content for advanced sink settings | No | - |
directory | Working directory for relative paths | No | - |
headers | Additional HTTP headers for the request (one per line, format: "Header-Name: value") | No | - |
additional-args | Additional arguments to pass to the cdviz-collector send command | No | - |
version | Version/tag of the cdviz-collector container to use | No | latest |
The action automatically passes all environment variables starting with CDVIZ_COLLECTOR__ to the cdviz-collector container. This allows you to override configuration values securely using GitHub secrets without exposing them in config files.
Environment variables should follow the pattern: CDVIZ_COLLECTOR__<SECTION>__<SUBSECTION>__<KEY>
Examples:
CDVIZ_COLLECTOR__SINKS__HTTP__HEADERS__X_API_KEY__VALUE→sinks.http.headers.x-api-key.valueCDVIZ_COLLECTOR__SINKS__HTTP__HEADERS__X_SIGNATURE__TOKEN→sinks.http.headers.x-signature.tokenCDVIZ_COLLECTOR__SINKS__HTTP__DESTINATION→sinks.http.destination
with:
data: | { "context": { "version": "0.4.1", "source": "github-actions", "type": "dev.cdevents.taskrun.started.0.2.0" }, "subject": { "id": "${{ github.run_id }}", "type": "taskRun", "content": { "taskName": "ci-build" } } }Tip
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:
with:
data: | { "context": { "version": "0.4.1", "source": "github-actions", "type": "dev.cdevents.taskrun.started.0.2.0" }, "subject": { "id": "${{ github.run_id }}", "type": "taskRun", "content": { "taskName": "ci-build" } } }with:
data: "@path/to/event.json"with:
data: "@-"You can provide TOML configuration content directly in the action:
config: | [sinks.http.headers.x-signature-256] type = "signature" token = "${{ secrets.WEBHOOK_SECRET }}" algorithm = "sha256" prefix = "sha256=" [sinks.http.headers.x-custom-header] type = "static" value = "custom-value"
⚠️ Security Note: Always use GitHub secrets (${{ secrets.SECRET_NAME }}) for sensitive information like API keys, tokens, and webhook secrets. Never hardcode sensitive values directly in your workflow files. The action creates a temporary config file with restrictive permissions in the workspace and automatically cleans it up after execution, even if the action fails.
- name: Send Build Started Eventuses: cdviz-dev/send-cdevents@v1with:
data: | { "context": { "version": "0.3.0", "id": "build-${{ github.run_id }}", "source": "github-actions", "type": "dev.cdevents.build.started.0.1.1", "timestamp": "${{ steps.timestamp.outputs.timestamp }}" }, "subject": { "id": "${{ github.repository }}", "source": "${{ github.server_url }}/${{ github.repository }}" } }url: ${{ secrets.CDEVENTS_WEBHOOK_URL }}- name: Send Test Started Eventuses: cdviz-dev/send-cdevents@v1with:
data: | { "context": { "version": "0.3.0", "id": "test-${{ github.run_id }}", "source": "github-actions", "type": "dev.cdevents.test.started.0.1.0", "timestamp": "${{ steps.timestamp.outputs.timestamp }}" }, "subject": { "id": "${{ github.repository }}", "source": "${{ github.server_url }}/${{ github.repository }}", "testCase": { "id": "${{ matrix.test-suite }}", "name": "${{ matrix.test-suite }}" } } }url: ${{ secrets.CDEVENTS_WEBHOOK_URL }}headers: | Authorization: Bearer ${{ secrets.API_TOKEN }} X-GitHub-Run-ID: ${{ github.run_id }}This project is licensed under the same license as the cdviz-collector project.