Skip to content
file-plus

GitHub Action

GitHub Copilot Usage Metrics API Export

v1.1 Latest version

GitHub Copilot Usage Metrics API Export

file-plus

GitHub Copilot Usage Metrics API Export

Export usage metrics from GitHub Copilot Usage Metrics API to a CSV file

Installation

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

              

- name: GitHub Copilot Usage Metrics API Export

uses: bthomas2622/[email protected]

Learn more about this action in bthomas2622/copilot-metrics-export-action

Choose a version

GitHub Copilot Usage Metrics API Export

This action exports usage metrics from the GitHub Copilot Usage Metrics API into a CSV file. The files are available as workflow artifacts in the GitHub Action run.

Inputs

Input Description Required Default
access-token The access token to use for authenticating with the GitHub API. See the eligible access token types and required permissions in the GitHub Copilot Usage Metrics API documentation. Yes -
enterprise-summary true or false on whether to generate a csv for Copilot usage for enterprise members. No false
enterprise-name The name/slug of the enterprise to generate a csv for. Example: myent for https://github.com/enterprises/myent. If enterprise-summary is true -
org-summary true or false on whether to generate a csv for Copilot usage for organization members. No false
org-name The name of the organization to generate a csv for. Example: myorg for https://github.com/myorg. No Name of organization that action is running in.
team-summary true or false on whether to generate a csv for Copilot usage for a team. No false
team-name The name of the team to generate a csv for. Example: engineering for https://github.com/orgs/myorg/teams/engineering. If team-summary is true -

Usage

In order to run this action you must create a GitHub Action workflow (.github/workflows/copilot-api-export.yml). See Creating a Workflow file.

Examples

name: Copilot Usage Metrics Export
on:
  workflow_dispatch:

jobs:
  run:
    name: Copilot Usage Metrics Export Action
    runs-on: ubuntu-latest
    steps:
      - uses: bthomas2622/[email protected]
        with:
          access-token: ${{ secrets.authorized-pat-here}}
          org-summary: true
          org-name: myorg
uses: bthomas2622/[email protected]
with:
  access-token: ${{ secrets.authorized-pat-here}}
  enterprise-summary: true
  enterprise-name: myenterprise
  org-summary: true
  org-name: myorg
  team-summary: true
  team-name: engineering

Creating an Access Token

See the eligible access token types and required permissions in the GitHub Copilot Usage Metrics API documentation.

Personal Access Tokens (Classic)

If you choose to utilize a Personal Access Token (PAT) (Classic) it must possess copilot, manage_billing:copilot, admin:org, admin:enterprise, or manage_billing:enterprise scope to use the Copilot Usage Metrics API endpoint.

Add this PAT as a secret so it can be used as input for access-token, see Creating encrypted secrets for a repository.

Organizations

If your organization has SAML enabled you must authorize the PAT, see Authorizing a personal access token for use with SAML single sign-on.

Downloading your files

The files are available as workflow artifacts in the GitHub Action run.

Screenshot 2024-04-24 at 9 06 11 AM