Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play

GitHub Action

CTO.ai Github Action

v1.2

CTO.ai Github Action

play

CTO.ai Github Action

This action extends the Ops Platform Github App to allow users to send in additional events and details of their workflow

Installation

Copy and paste the following snippet into your .yml file.

              

- name: CTO.ai Github Action

uses: cto-ai/action@v1.2

Learn more about this action in cto-ai/action

Choose a version

Test

CTO.ai GitHub Action

This Github Action allows you to extend the insights data received by CTO.ai Github App. You can add data to you workflows for deployment tools that are not configured with Github's deployment API.

Required Inputs

token

CTO.ai api token, follow these docs to generate

team_id

CTO.ai team ID sending the data, follow these docs to access

event_name

Name of event being sent i.e. "deployment"

event_action

Action associated with event i.e. "failed", "pending", or "succeeded"

Optional Inputs

environment

Environment that workflow is running in.

image

Built image id if available

branch

Branch used to reference where change is taking place (If not present, action will try to use ref value if available to event type)

commit

Commit id to uniquely reference the event (If not present, action will try to use SHA value if available to event type)

Recommendations

Create 2 new secrets for your token and team_id to be passed into the action.

  1. From your GitHub repo, click Settings -> Secrets -> New Secret
  • Create CTOAI_TEAM_ID secret using your CTO.ai-issued Team Id.
  • Create CTOAI_EVENTS_API_TOKEN secret using your CTO.ai-issued API Token.

Example Usage

If you have a GitHub workflow that deploys your application (i.e. serverless, npm publish, Azure, etc), you can drop this Action in right after that step to capture the success or fail of that deployment!

We recommend adding environment to help us help you differentiate multiple deployment events from the same repository to different environments or workflows. This will be reflected on your Insights Dashboard.

- name: Report Deployment Succeeded
  if: ${{ success() }}
  uses: cto-ai/action@v1.2
  id: ctoai-deployment-succeeded
  with:
    team_id: ${{ secrets.CTOAI_TEAM_ID }}
    token: ${{ secrets.CTOAI_EVENTS_API_TOKEN }}
    event_name: "deployment"
    event_action: "succeeded"
    environment: "production"
- name: Report Deployment Failed
  if: ${{ failure() }}
  uses: cto-ai/action@v1.2
  id: ctoai-deployment-failed
  with:
    team_id: ${{ secrets.CTOAI_TEAM_ID }}
    token: ${{ secrets.CTOAI_EVENTS_API_TOKEN }}
    event_name: "deployment"
    event_action: "failed"
    environment: "production"