Skip to content

The Copilot Usage Metrics API supplies data spanning a 28-day timeframe. This Action is designed to persistently store this data over time in a JSON file format.

License

Notifications You must be signed in to change notification settings

admin-hsu1/copilot-metrics-retention

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copilot Metrics Retention

The Copilot Usage Metrics API supplies data spanning a 28-day timeframe. This Action is designed to persistently store this data over time in a JSON file format. This Action generates the Copilot Usage Metrics data in a JSON file format and stores it in the repository. Each time the Action is executed, the JSON file is refreshed to incorporate the delta data retrieved from the API.

Note:

PAT Token

Create a Fine-grained personal access tokens with

  • Resource owner as Organization
  • read & write access to GitHub Copilot for Business under Organization permissions gh image

Pass this token as an input to the action - GITHUB_TOKEN

Usage in workflow

Incorporate the copilot-metrics-retention action into your workflow and initiate the workflow either manually or through a schedule.

Sample workflow file:

    name: Copilot Metrics Retention

    on:
     workflow_dispatch:
      inputs:
          org_name: 
            description: 'Organization name'
            required: true
            default: 'octodemo'
          json_path:
            description: 'JSON File path'
            required: true
            default: 'metrics.json'
         
    jobs:
     first-job:
     runs-on: ubuntu-latest
    
     steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Copilot Metrics Retention 
        uses: ambilykk/copilot-metrics-retention@main
        with:        
          GITHUB_TOKEN: ${{ secrets.ORG_TOKEN }}
          org_name: ${{ inputs.org_name }} 
          json_path: ${{ inputs.json_path }} 
    
      - name: Commit and push if it changed
        run: |
            git config --global user.name 'Copilot Metrics Retention'
            git config --global user.email '[email protected]'
            git add -A
            git diff --quiet && git diff --staged --quiet || git commit -m "Copilot Metrics data update"
            git push
     

Parameters

Name Required Description
GITHUB_TOKEN Yes PAT Token for access
org_name Yes GitHub Organization Name
json_path Yes JSON file path to store the Copilot Metrics dtaa in repository

License

The scripts and documentation in this project are released under the MIT License

About

The Copilot Usage Metrics API supplies data spanning a 28-day timeframe. This Action is designed to persistently store this data over time in a JSON file format.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%