GitHub Actions Integration

Integrate Kosli with GitHub Actions workflows for automated change tracking and compliance evidence collection

Overview

This guide demonstrates how to integrate Kosli with GitHub Actions workflows to automatically track deployments, collect compliance evidence, and maintain audit trailsβ€”all without slowing down your delivery pipeline.

Prerequisites

  • Kosli account and API token

  • GitHub repository with Actions enabled

  • Docker or deployable artifacts

  • Kubernetes or deployment target

Setup

1. Configure GitHub Secrets

Add these secrets to your repository (Settings > Secrets and variables > Actions):

KOSLI_API_TOKEN      # Your Kosli API token
KOSLI_ORG            # Your Kosli organization name

2. Install Kosli CLI Action

Use the official Kosli setup action in your workflow:

Basic Workflow

Complete Example

.github/workflows/deploy.yml:

Step-by-Step Integration

Step 1: Report Artifact

Report your built artifact (Docker image, binary, etc.):

What this does:

  • Creates cryptographic fingerprint of the artifact

  • Links artifact to Git commit

  • Records build URL for traceability

Step 2: Report Test Evidence

Report test results as evidence:

Supports:

  • JUnit XML format

  • Test pass/fail counts

  • Test execution time

Step 3: Report Security Scan

Report security scanning results:

Alternative Scanners:

  • Snyk: snyk container test --json-file-output=snyk.json

  • Grype: grype -o json myapp:${{ github.sha }}

  • Anchore: anchore-cli image scan myapp:${{ github.sha }}

Step 4: Report Deployment

Report when artifact is deployed:

Step 5: Snapshot Environment

Verify what's actually running:

Advanced Patterns

Matrix Deployments

Deploy to multiple environments:

Conditional Evidence

Only collect certain evidence in specific scenarios:

Reusable Workflow

Create a reusable workflow for Kosli tracking:

.github/workflows/kosli-report.yml:

Use the reusable workflow:

Pull Request Evidence

Report PR approvals as evidence:

Scheduled Environment Snapshots

Run periodic snapshots to detect drift:

Error Handling

Graceful Failure

Don't fail deployments if Kosli reporting fails (but log the issue):

Retry Logic

Implement retry for transient failures:

Best Practices

1. Report Early, Deploy Later

Report artifacts and evidence before deployment:

βœ… Good:

❌ Bad:

2. Include Contextual Information

Provide rich context in your reports:

3. Use Environment-Specific Flows

Separate flows for different criticality levels:

4. Snapshot After Deployment

Always snapshot after deploying to verify:

Troubleshooting

Authentication Issues

Artifact Fingerprint Issues

If fingerprints don't match between report and deployment:

Next Steps

Additional Resources

Last updated