OpsTrailsDocs
Console

GitHub Actions

Automatically track deployments from GitHub Actions workflows using the official opstrails/track-event action.

Setup

  1. Go to your repository's Settings → Secrets and variables → Actions
  2. Add a new secret named OPSTRAILS_API_KEY with a READ_WRITE API key

Workflow Step

Add the following step to your deployment workflow:

yaml
- uses: opstrails/track-event@v1
  with:
    api-key: ${{ secrets.OPSTRAILS_API_KEY }}
    type: deployment
    subject: production
    version: ${{ github.sha }}
    description: "Deployed to production"

Inputs

InputRequiredDescription
api-keyrequiredOpsTrails API key (READ_WRITE scope)
typerequiredEvent type (e.g. deployment, rollback)
subjectoptionalTarget environment (e.g. production)
versionoptionalRelease version or commit SHA
descriptionoptionalHuman-readable description

Full Workflow Example

yaml
name: Deploy
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Deploy to production
        run: ./deploy.sh

      - name: Track deployment
        uses: opstrails/track-event@v1
        with:
          api-key: ${{ secrets.OPSTRAILS_API_KEY }}
          type: deployment
          subject: production
          version: ${{ github.sha }}
          description: "Deployed ${{ github.repository }} to production"