From 65f04632131b8377067b4367f757b99c1b850611 Mon Sep 17 00:00:00 2001 From: Kyle Campbell Date: Fri, 25 Sep 2020 02:39:43 -0700 Subject: [PATCH] remove readme section for manual instrumentation --- README.md | 36 ------------------------------------ index.js | 25 ++++++++++++++----------- 2 files changed, 14 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 9c24a22..412f55e 100644 --- a/README.md +++ b/README.md @@ -21,42 +21,6 @@ dashboard. 4. You're done! Delivery & LifeCycle Metrics can now be viewed on the Metrics Dashboard. -## Manually Instrument Pipelines using the CTO.ai Action - -In addition to the drop-in Agent, you can manually instrument your GitHub -action workflows with specific LifeCycle events that you specify. For example, -if you have a GitHub workflow that deploys your application to Azure, you could -add steps to this workflow that use the CTO.ai Action (cto-ai/action) to store -metrics. The CTO.ai Action will store the event information that you specify, -and those metrics can then be visible on the CTO.ai Delivery Metrics Dashboard. - -The CTO.ai steps that you can add to your workflows look like this: - -``` -- name: Report Build Succeeded - if: ${{ success() }} - uses: cto-ai/action@v1-beta - id: ctoai-build-succeeded - with: - team_id: ${{ secrets.CTOAI_TEAM_ID }} - token: ${{ secrets.CTOAI_EVENTS_API_TOKEN }} - stage: "Build" - status: "Succeeded" - change-id: "your-change-id1" - pipeline-id: "your-pipeline-id1" -- name: Report Build Failed - if: ${{ failure() }} - uses: cto-ai/action@v1-beta - id: ctoai-build-failed - with: - team_id: ${{ secrets.CTOAI_TEAM_ID }} - token: ${{ secrets.CTOAI_EVENTS_API_TOKEN }} - stage: "Build" - status: "Failed" - change-id: "your-change-id1" - pipeline-id: "your-pipeline-id1" -``` - See a live example of this instrumentation in the [deployment-action-example](https://github.com/cto-ai/deployment-action-example) repo, which instruments an Azure deployment pipeline. diff --git a/index.js b/index.js index 700f899..d950fd3 100644 --- a/index.js +++ b/index.js @@ -48,16 +48,21 @@ try { core.setFailed(err.message); } -function mapEventsByRepo(github) { +function mapEventsByFeature(github) { + + return { + 'team_id': `${CTOAI_EVENTS_TEAM_ID}`, + 'pipeline_id': `${process.env.GITHUB_REPOSITORY}`, + 'stage': `${snakeToTitleCase(get(github, ['context', 'eventName']))}`, + 'status': `${snakeToTitleCase(get(github, ['context', 'payload', 'action'])) || 'Succeeded'}`, + 'change_id': `${github.context.sha}`, + 'stage_ref': `${process.env.GITHUB_REF.replace('refs/heads/','')}`, + 'custom': github + } - // console.log('API URL:', CTOAI_EVENTS_API_URL) - // console.log('team_id', CTOAI_EVENTS_TEAM_ID); - // console.log('pipeline_id:', process.env.GITHUB_REPOSITORY) - // console.log('stage:', snakeToTitleCase(get(github, ['context', 'eventName']))) - // console.log('status:', snakeToTitleCase(get(github, ['context', 'payload', 'action'])) || 'Success') - // console.log('change_id:', github.context.sha) - // console.log('stage_ref:', process.env.GITHUB_REF.replace('refs/heads/','')) - // console.log(process.env); +} + +function mapEventsByRepo(github) { return { 'team_id': `${CTOAI_EVENTS_TEAM_ID}`, @@ -108,8 +113,6 @@ function isMatchedEvent (github) { } ]; - // Defines the HTTP request body to be used by the event with the matching - // name. const event_bodies = { "Change Initiated" : { 'stage': `Change`,