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

GitHub Action

Copilot Usage Action

v2

Copilot Usage Action

bar-chart-2

Copilot Usage Action

Get reports on GitHub Copilot Usage

Installation

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

              

- name: Copilot Usage Action

uses: austenstone/copilot-usage@v2

Learn more about this action in austenstone/copilot-usage

Choose a version

Copilot Usage Action

OpenSSF Best Practices

Get Copilot usage data as:

  • Md Job Summary
  • CSV
  • XML
  • JSON

Powered by the REST API endpoints for GitHub Copilot usage metrics.

Usage

Create a workflow (eg: .github/workflows/copilot-usage.yml). See Creating a Workflow file.

PAT(Personal Access Token)

You will need to create a PAT(Personal Access Token) that has the copilot, manage_billing:copilot, admin:org, admin:enterprise, or manage_billing:enterprise scope to use this endpoint.

Add this PAT as a secret so we can use it as input github-token, see Creating encrypted secrets for a repository.

Basic Example

The default behavior is to get the usage for the repository owner which is likely the organization.

Important

You need to set the secret TOKEN in your repository settings.

name: Copilot Usage
on:
  schedule:
    - cron: '0 0 * * *'
  workflow_dispatch:

jobs:
  run:
    name: Run Action
    runs-on: ubuntu-latest
    steps:
      - uses: austenstone/copilot-usage@v3
        with:
          github-token: ${{ secrets.TOKEN }}

Example get team usage

      - uses: austenstone/copilot-usage@v3
        with:
          github-token: ${{ secrets.TOKEN }}
          organization: 'org-slug'
          team: 'team-slug'

Example get enterprise usage

      - uses: austenstone/copilot-usage@v3
        with:
          github-token: ${{ secrets.TOKEN }}
          enterprise: 'enterprise-slug'

Example sending email PDF report

Important

You must set secrets for EMAIL and PASSWORD to send the email. You must use an App Password for Gmail.

name: Email Copilot Report
on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'

jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - uses: austenstone/copilot-usage@v3
        with:
          github-token: ${{ secrets.TOKEN }}
      - uses: austenstone/job-summary-to-pdf@v1.0
        id: pdf
        with:
          name: copilot-usage
      - uses: dawidd6/action-send-mail@v3
        with:
          server_address: smtp.gmail.com
          server_port: 465
          username: ${{ secrets.EMAIL }}
          password: ${{ secrets.PASSWORD }}
          from: ${{ secrets.EMAIL }}
          to: ${{ secrets.EMAIL }} # Recipient email
          subject: "Copilot Usage Report (${{ steps.usage.outputs.since }} - ${{ steps.usage.outputs.until }})"
          body: "Attached is the Copilot Usage Report for ${{ steps.usage.outputs.since }} - ${{ steps.usage.outputs.until }}!"
          attachments: ${{ steps.pdf.outputs.pdf-file }}

Tip

Try using other messaging systems such as slack, teams, discord, etc.

image

➡️ Inputs

We look first for enterprise input, then team, and finally organization. If none are provided, we default to the repository owner which is likely the organization.

Various inputs are defined in action.yml:

Name Description Default
github-token The GitHub token used to create an authenticated client ${{ github.token }}
enterprise The GitHub enterprise slug
organization The organization slug ${{ github.repository_owner }}
team The team slug
days The number of days to show usage metrics for
since Show usage metrics since this date. This is a timestamp in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). Maximum value is 28 days ago
until Show usage metrics until this date. This is a timestamp in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). Maximum value is 28 days ago
job-summary Whether to generate a report true
csv Whether to generate a CSV as a workflow artifact false
csv-options The options for the CSV report
xml Whether to generate an XML as a workflow artifact false
xml-options The options for the XML report

⬅️ Outputs

Name Description
result The copilot usage as a JSON string
since The date since which the usage metrics are shown
until The date until which the usage metrics are shown

Example Job Summary

Copilot Usage
3/30/2024 - 4/24/2024

Suggestions: 198,449

Acceptances: 51,532

Acceptance Rate: 25.97%

Lines of Code Accepted: 87,151

---
config:
    xyChart:
        width: 1125
        height: 500
        xAxis:
            labelPadding: 20
    themeVariables:
        xyChart:
            backgroundColor: "transparent"
---
xychart-beta
  title "Accepts & Acceptance Rate"
  x-axis ["03/30", "03/31", "04/01", "04/02", "04/03", "04/04", "04/06", "04/07", "04/08", "04/09", "04/10", "04/11", "04/12", "04/13", "04/14", "04/15", "04/16", "04/17", "04/18", "04/19", "04/20", "04/21", "04/22", "04/23", "04/24"]
  y-axis "Acceptances" 0 --> 3204
  bar [1523, 1859, 1815, 2237, 2240, 3067, 1476, 1901, 2380, 2391, 2600, 3194, 2137, 672, 1393, 2063, 1945, 1935, 2074, 2137, 627, 1607, 2658, 2735, 2866]
  line [814.2319372601368, 851.499070764832, 852.8024637043554, 845.6050023596036, 802.5226434082522, 766.4509788628031, 884.7715622076707, 931.4580211041444, 888.0307441481309, 765.4640287769785, 808.6981846422677, 866.4445008890017, 751.9986820428336, 871.6955465587045, 820.4360294117646, 735.6540901502505, 724.3728931767988, 710.7348389315603, 865.4722584006253, 840.6320441988951, 932.2078886310904, 1273.5166955231264, 861.2694174757282, 855.2547335545579, 888.9316553727009]
Loading
---
config:
    xyChart:
        width: 1125
        height: 500
        xAxis:
            labelPadding: 20
    themeVariables:
        xyChart:
            backgroundColor: "transparent"
---
xychart-beta
  title "Daily Active Users"
  x-axis ["03/30", "03/31", "04/01", "04/02", "04/03", "04/04", "04/06", "04/07", "04/08", "04/09", "04/10", "04/11", "04/12", "04/13", "04/14", "04/15", "04/16", "04/17", "04/18", "04/19", "04/20", "04/21", "04/22", "04/23", "04/24"]
  y-axis "Active Users" 0 --> 139
  line [33, 35, 70, 106, 101, 118, 32, 38, 96, 112, 125, 116, 105, 25, 36, 91, 106, 97, 97, 96, 30, 32, 116, 118, 129]
Loading

Language Usage

pie showData
title Language Usage
    "markdown" : 46441
"typescript" : 27172
"python" : 18868
"typescriptreact" : 17351
"javascript" : 16876
"rust" : 8557
"yaml" : 8030
"ruby" : 7136
"go" : 6162
"java" : 5043
"unknown" : 4318
"text" : 4275
"shell" : 3469
"c#" : 3025
"github-actions-workflow" : 2424
"css" : 2422
"html" : 2266
"json" : 1685
"hcl" : 1298
"vue" : 1022
Loading
LanguageSuggestionsAcceptancesAcceptance RateLines SuggestedLines AcceptedActive Users
typescript27172827630.46%4540713864327
markdown46441727215.66%666108292377
python18868680036.04%2991210480354
javascript16876561833.29%3305411717453
typescriptreact17351458326.41%282746721299
yaml8030247630.83%149904342287
ruby7136214029.99%118282670199
java5043204540.55%178296515220
rust8557198223.16%40011406773
go6162180029.21%106942585109
c#3025119239.40%75372726146
shell3469102129.43%54011393132
github-actions-workflow242479332.71%4637149861
html226671731.64%83771553124
unknown431862814.54%7298831103
css242255522.91%5062103197
text42753889.08%2386453378
json168534520.47%3446711137
hcl129834026.19%4501109855
fsharp87231536.12%209673636
dockerfile66724436.58%79325049
sql52221641.38%91843369
vue102219018.59%237527616
emacs-lisp56415327.13%114330018
powershell59513823.19%79515631
scss81712815.67%146414439
ql80711714.50%172015724
kotlin1777743.50%70835613
json with comments738709.49%12358063
r3887018.04%6907216
blazor3116219.94%94311518
xml1515939.07%50724539
jade1515737.75%2551045
postcss1384633.33%296647
lua3484512.93%1523667
javascriptreact644367.19%197737
toml2674115.36%8575423
astro1253830.40%3911228
razor953031.58%2183716
html+erb1922814.58%2953419
mdx250249.60%2972410
terraform-vars642437.50%79246
html.erb1072422.43%244518
vs-markdown1492416.11%149247
ini1462013.70%1902012
dotenv1062018.87%1201713
php1021817.65%3012417
c++701825.71%1363415
bicep631726.98%1203910
postgres1171714.53%247614
dart721723.61%143197
groovy711521.13%1252015
ignore list1241512.10%1411524
sas711419.72%116172
dockercompose331030.30%74399
django-txt201050.00%24102
puppet44920.45%111267
rjsx30930.00%107622
git-commit28882.78%355819
prisma17847.06%332410
tex55610.91%7369
kusto47612.77%76107
liquid10665.66%379162
scminput5958.47%152510
graphql21523.81%81273
julia20420.00%2473
aspnetcorerazor8450.00%30124
helm18316.67%2036
cobol7342.86%832
makefile14321.43%1737
vb4375.00%844
objective-c5360.00%31152
pug8337.50%934
scala6350.00%2322
gotemplate8225.00%1632
vim11218.18%2722
perl4824.17%6027
nunjucks1417.14%1617
properties2813.57%4318
mermaid6116.67%712
pip-requirements2613.85%2815
nix1218.33%2812
rmd3812.63%4412
django-html3133.33%1192
eruby11100.00%442
postgresql6116.67%913
clojure900.00%1102
objective-cpp1200.00%1202
code++.ini300.00%701
protocol buffer100.00%101
zsh400.00%1803
ssh_config100.00%101
swift200.00%301
gemfile700.00%802
msbuild100.00%301
conf300.00%1001
sshconfig900.00%3303
plm400.00%501
restructuredtext100.00%101
csv200.00%302
bat200.00%202
vgo900.00%1401
hcl.terraform100.00%301
coffeescript500.00%603
http request100.00%101
requirements400.00%401
emd700.00%702
c200.00%201
sqlite200.00%201

Editor Usage

pie showData
title Editor Usage
    "vscode" : 178187
"neovim" : 10531
"jetbrains" : 6818
"visual_studio" : 2179
"emacs" : 616
"vim" : 113
Loading
EditorSuggestionsAcceptancesAcceptance RateLines SuggestedLines AcceptedActive Users
vscode1781874604325.84%321088765073911
neovim10531250923.82%504954938133
jetbrains6818195928.73%147943583315
visual_studio217982437.82%45771673105
emacs61616727.11%133238924
vim1132925.66%3585719

Daily Usage

The most active day was 4/24/2024 with 129 active users.

The day with the highest acceptance rate was 4/21/2024 with an acceptance rate of 39.75%.

pie showData
title Suggestions by Day of the Week
"Sunday" : 23017
"Monday" : 34279
"Tuesday" : 37333
"Wednesday" : 38297
"Thursday" : 32310
"Friday" : 17250
"Saturday" : 15963
Loading
DaySuggestionsAcceptancesAcceptance RateLines SuggestedLines AcceptedActive UsersChat AcceptancesChat TurnsActive Chat Users
3/30/20245993152325.41%15527270933000
3/31/20246995185926.58%17328304435000
4/1/20246819181526.62%29475316970000
4/2/20248476223726.39%144643768106000
4/3/20248943224025.05%199764386101000
4/4/202412821306723.92%270085982118000
4/6/20245345147627.61%10927243332000
4/7/20246539190129.07%13533361138000
4/8/20248587238027.72%16254461896000
4/9/202410008239123.89%185424514112000
4/10/202410301260025.24%188254752125000
4/11/202411811319427.04%206365512116000
4/12/20249105213723.47%144783554105000
4/13/2024247067227.21%375688025000
4/14/20245440139325.61%8604197536000
4/15/20248985206322.96%13923322491000
4/16/20248603194522.61%164033608106000
4/17/20248723193522.18%16341338097000
4/18/20247678207427.01%13713288597000
4/19/20248145213726.24%15544344296000
4/20/2024215562729.10%408299230000
4/21/20244043160739.75%7207221132000
4/22/20249888265826.88%185754119116000
4/23/202410246273526.69%1745041201183161631107
4/24/202410330286627.74%2009042631293492193116
Manage Access for {org}

Further help

To get more help on the Actions see documentation.