austenstone / copilot-license-cleanup

Automatically remove inactive Copilot licenses

Home Page:https://github.com/austenstone/copilot-license-cleanup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copilot License Cleanup

Run this action on a schedule to automatically remove inactive Copilot licenses. It also creates a report as a job summary and csv.

Usage

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

PAT(Personal Access Token)

You will need to create a PAT(Personal Access Token) that has manage_billing:copilot access.

Add this PAT as a secret TOKEN so we can use it for input github-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.

Example

name: Cleanup Copilot Licenses
on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'

jobs:
  copilot:
    name: Copilot Seats
    runs-on: ubuntu-latest
    steps:
      - uses: austenstone/copilot-license-cleanup@v1.1
        with:
          github-token: ${{ secrets.TOKEN }}

Example Auto remove

      - uses: austenstone/copilot-license-cleanup@v1.1
        with:
          github-token: ${{ secrets.TOKEN }}
          remove: true
          remove-from-team: true

Example Custom days before inactive

      - uses: austenstone/copilot-license-cleanup@v1.1
        with:
          github-token: ${{ secrets.TOKEN }}
          remove: true
          remove-from-team: true
          inactive-days: 10
Job summary example

➡️ Inputs

Various inputs are defined in action.yml:

Name Description Default
github‑token Token to use to authorize. ${{ github.token }}
organization The organization to use for the action ${{ github.repository_owner }}
remove Whether to remove inactive users false
remove-from-team Whether to remove inactive users from their assigning team false
inactive‑days The number of days to consider a user inactive 90
job-summary Whether to output a summary of the job true
csv Whether to output a CSV of inactive users false

⬅️ Outputs

Name Description
inactive-seats JSON array of inactive seats
inactive-seat-count The number of inactive seats
removed-seats The number of seats removed
seat-count The total number of seats

How does it work?

We're simply leveraging the GitHub Copilot API. First we fetch all the Copilot seats and filter them to only inactive seats. Then if the seat is assigned directly we remove it but if it's assigned through a team we remove the user from the team. Those inactive users are reported as a CSV and a job summary table.

Further help

To get more help on the Actions see documentation.

About

Automatically remove inactive Copilot licenses

https://github.com/austenstone/copilot-license-cleanup


Languages

Language:TypeScript 100.0%