The CTO.ai GitHub Action flips the pattern of integration with our platform—from passively collecting the user activity in your repo used for deriving Insights, to actively pushing the events defining your development workflow to the CTO.ai platform.
If you’re already comfortable with using GitHub Actions or just prefer having granular control of the events collected by the CTO.ai platform, we provide our own Action for you to drop into your existing workflows on GitHub. By explicitly defining when our Action runs within your GitHub Actions workflow, you can send Events to the CTO.ai platform at the points in your existing workflow that make the most sense. This additional level of control also makes it possible to fine-tune the metrics sent to our platform, improving the accuracy of the Insights we derive for complex collaborative processes.
Configuring GitHub Actions
Before you can configure our GitHub Action as part of your GitHub workflow, you will need credentials.
A Secret Key and Client ID, which can be obtained by contacting support.
For more information about the Deployment Events and Change Events that the CTO.ai platform can receive and use for deriving Insights about your development lifecycle, have a look at our Insights Events documentation.
Usage Examples
The examples below demonstrate some of the ways our GitHub Action can be used to track the milestones of your workflow.
⚠️
Warning
The value defined by the event_name and event_action keys should always be written in lowercase letters, for example:
event_name: deployment
event_action: "success"
event_action: failure
Remember that quoting YAML string values is optional when the string doesn’t contain special characters.
Please note that these examples don’t include the steps you might use to deploy your application; rather, they demonstrate how you can integrate our GitHub Action in the context of your existing workflows.
This example workflow definition shows how to use our GitHub Action to track deployments that result from changes being pushed to a specific branch in your GitHub repo.
name: Deployment Metricson:
push:
branches:
- mainjobs:
ctoai-metrics:
runs-on: ubuntu-lateststeps:
# This is one possible place that you might write the# deployment steps specific to your application.# For example:## - name: Your Deployment Action# uses: your-org/[email protected]# with:# token: ${{ secrets.OTHER_INFRA_TOKEN }} - name: "Report Deployment Succeeded"if: ${{ success() }}uses: cto-ai/[email protected]with:
team_id: ${{ secrets.CTOAI_TEAM }}token: ${{ secrets.CTOAI_TOKEN }}event_name: "deployment"event_action: "success" - name: "Report Deployment Failed"if: ${{ failure() }}uses: cto-ai/[email protected]with:
team_id: ${{ secrets.CTOAI_TEAM }}token: ${{ secrets.CTOAI_TOKEN }}event_name: "deployment"event_action: "failure"
This example workflow definition shows how to use our GitHub Action to track deployments that result from changes being pushed to a specific tag in your GitHub repo.
name: Deployment Metricson:
push:
tags:
- v*jobs:
ctoai-metrics:
runs-on: ubuntu-lateststeps:
# This is one possible place that you might write the# deployment steps specific to your application.# For example:## - name: Your Deployment Action# uses: your-org/[email protected]# with:# token: ${{ secrets.OTHER_INFRA_TOKEN }} - name: "Report Deployment Succeeded"if: ${{ success() }}uses: cto-ai/[email protected]with:
team_id: ${{ secrets.CTOAI_TEAM }}token: ${{ secrets.CTOAI_TOKEN }}event_name: "deployment"event_action: "success" - name: "Report Deployment Failed"if: ${{ failure() }}uses: cto-ai/[email protected]with:
team_id: ${{ secrets.CTOAI_TEAM }}token: ${{ secrets.CTOAI_TOKEN }}event_name: "deployment"event_action: "failure"
This example workflow definition shows how to use our GitHub Action to track events when you make use of the GitHub Releases feature to deploy your application to your cloud environment.
name: Deployment Metricson:
release:
types: [published, deleted]jobs:
ctoai-metrics:
runs-on: ubuntu-lateststeps:
# This is one possible place that you might write the# deployment steps specific to your application.# For example:## - name: Your Deployment Action# uses: your-org/[email protected]# with:# token: ${{ secrets.OTHER_INFRA_TOKEN }} - name: "Report Deployment Succeeded"if: github.event.action == 'published' && github.event.release.prerelease == falseuses: cto-ai/[email protected]with:
team_id: ${{ secrets.CTOAI_TEAM }}token: ${{ secrets.CTOAI_TOKEN }}event_name: "deployment"event_action: "succeess" - name: "Report Deployment Failed"if: github.event.action == 'deleted' && github.event.release.prerelease == falseuses: cto-ai/[email protected]with:
team_id: ${{ secrets.CTOAI_TEAM }}token: ${{ secrets.CTOAI_TOKEN }}event_name: "deployment"event_action: "failure"