Generating Custom GitHub Events

You can integrate mabl events with your GitHub Workflows. This allows mabl to trigger your custom workflows inside GitHub based on events occurring in mabl.

Once configured in Settings > Integrations, mabl will send a custom RepositoryDispatch event to the corresponding GitHub repository when a mabl insight results from your mabl CI/CD integration (e.g. on a deployment of your application).

Supported mabl generated GitHub events

  • mabl_insight - sent when a mabl insight is generated

See example payloads for more details.

How to start creating GitHub events automatically

Follow the GitHub integration setup instructions to install the integration.

Be sure to click the Create RepositoryDispatch events for mabl insights slider and click Save, when configuring the integration.

How to use mabl events in your GitHub Workflows

Copy the following example YAML file to .github/workflows/trigger-on-mabl-insight.yml in the GitHub repository that is used in your mabl CI/CD integration.

When an insight is generated in mabl, based on mabl tests run against this repository, the code in the aforementioned workflow will be triggered, with the mabl insight passed into the workflow as the github context variable with the name github.event.client_payload.insight

name: Process mabl insight
# This workflow is triggered on new mabl insights
on: [repository_dispatch]

jobs:
  build:
    name: Process mabl Insight
    runs-on: ubuntu-latest
    steps:
      # Add you custom logic below this line - example below
      - name: Print event type
        run: echo 'event_type:${{ github.event.event_type }} name:${{ github.event_name }}' # Will be 'mabl_insight'
      - name: Print Insight details
        run: echo 'id:${{ github.event.client_payload.insight.id }} type:${{ github.event.client_payload.insight.insight_type }}'
      - name: Print Insight payload as JSON
        run: echo 'insight payload: ${{ toJson(github.event.client_payload.insight) }}'

Managing GitHub issue creation

See configuring the GitHub integration for full details on customizing this feature's behavior.

Example event payloads

mabl_insight

{
  "id": "jHn6br1LOm10MwEsPjURxQ-i",
  "workspace_id": "nKqPRcj1Rrm8zqgb3KeTSQ-w",
  "environment_id": "otnJ3IeoWm4zwmoVFz7ppA-e",
  "application_id": "RePxEygYbhJdPbjgGqywPTw-a",
  "run_policy_id": "yWud5dtC7OEPXp2akr6Dzg-p",
  "plan_id": "yWud5dbAraEPPjSRkr6Dzg-p",
  "created_time": 1579186926230,
  "last_updated_time": 1579186927108,
  "type": "occurrence_run_policy_execution_system_event",
  "current_state": "occurrence",
  "status": "info",
  "category": "run_policy_execution_system_event",
  "context": {
    "triggering_resource_type": "user",
    "triggering_resource_id": "dXAi-GwSvITmihOKLu5k0KQ",
    "system_event": "run_policy_execution",
    "trigger_type": "schedule"
  },
  "plan_run_id": "iG8I5bI8lpQm53yJRHA9JA-pr",
}

Did this page help you?