Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

15 Commits

Repository files navigation

Send CDEvents GitHub Action

A GitHub Action that sends CDEvents using the cdviz-collector send subcommand.

Usage

Basic Example

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"

Advanced Example with Headers

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: GitHub

Using Configuration Content

name: 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="

Using Environment Variables for Secrets

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="

Reading from File

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"

Inputs

InputDescriptionRequiredDefault
dataJSON data to send. Can be direct JSON string, file path (@file.json), or stdin (@-)Yes-
urlHTTP URL to send the data to. When specified, automatically enables the HTTP sinkNo-
configTOML configuration content for advanced sink settingsNo-
directoryWorking directory for relative pathsNo-
headersAdditional HTTP headers for the request (one per line, format: "Header-Name: value")No-
additional-argsAdditional arguments to pass to the cdviz-collector send commandNo-
versionVersion/tag of the cdviz-collector container to useNolatest

Environment Variables

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 Variable Naming Convention

Environment variables should follow the pattern: CDVIZ_COLLECTOR__<SECTION>__<SUBSECTION>__<KEY>

Examples:

  • CDVIZ_COLLECTOR__SINKS__HTTP__HEADERS__X_API_KEY__VALUEsinks.http.headers.x-api-key.value
  • CDVIZ_COLLECTOR__SINKS__HTTP__HEADERS__X_SIGNATURE__TOKENsinks.http.headers.x-signature.token
  • CDVIZ_COLLECTOR__SINKS__HTTP__DESTINATIONsinks.http.destination

Data Input Formats

Direct JSON String

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" } } }

From File

with:
data: "@path/to/event.json"

From Stdin (for piped data)

with:
data: "@-"

Configuration Content Example

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.

Examples

Build Event

- 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 }}

Test Event

- 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 }}

License

This project is licensed under the same license as the cdviz-collector project.

About

A github action to send cdevents (using `cdviz-collector send`)

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors