Skip to content

Commit

Permalink
refactor: copilot project
Browse files Browse the repository at this point in the history
  • Loading branch information
daabr committed Jan 4, 2025
1 parent 43e9afc commit 3913c22
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 232 deletions.
38 changes: 21 additions & 17 deletions github_copilot_seats/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
---
title: Unregister non active users from Copilot
description: If Copilot was not used in a preceding period by users, the workflow automatically unregisters and notifies them. Users can ask for their subscription to be reinstated.
title: Cancel GitHub Copilot access for inactive users
description: If Copilot was not used in a preceding period by users, unsubscribe and notify them in Slack. Users can ask for their subscription to be reinstated.
integrations: ["githubcopilot", "slack"]
categories: ["DevOps"]
---

# GitHub Copilot Registration Pruning
# GitHub Copilot Seat Pruning

This automation searches daily for all users in a GitHub organization that are actively using Copilot.
If Copilot was not used in a preceding period, it automatically unregisters them, and then notifies them.
Users can then optionally ask for their subscription to be reinstated.
This automation enumerates once a day all the users in the GitHub organization
that have access to [Copilot](https://github.com/features/copilot). If any of
them haven't used it in a preceding period of time, it automatically marks
their seat for cancellation in the next billing cycle, and notifies them in a
Slack DM.

## Before Deploying This AutoKitteh Project:
Users can then optionally respond and ask for the seat to be reassigned back
to them.

- Set the `GITHUB_ORG` in the project's vars.
- Set the `IDLE_USAGE_THRESHOLD` in the project's vars:
- (e.g., `4320` for 72 hours)
- (e.g., `25` for 25 minutes)
- Set the `LOGINS` in the project's vars (optional).
- Set the `LOG_CHANNEL` in the project's vars to the Slack channel name/ID you want to post to.
## Before Deploying This AutoKitteh Project

Set/modify these optional project variables:

- `IDLE_HOURS_THRESHOLD` (default = 72 hours)
- `MANAGED_LOGINS` (default = no one = manage all org users)
- `SLACK_LOG_CHANNEL` (default = `"copilot-log"`, `""` = no logging in Slack)

## Slack Usage

- `/autokitteh prune-idle-copilot-seats` invokes the automation immediately.
- `/autokitteh find-idle-copilot-seats` displays the potentially idle seats.
You may use the Slack application's slash command(s) with one of these text
triggers:

> [!WARNING]
> This example currently works only with a [Personal Access Token](https://docs.autokitteh.com/integrations/github/connection/#personal-access-token-pat), specifically a [classic token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic).
- `prune-idle-copilot-seats` - invokes the daily automation immediately
- `find-idle-copilot-seats` - displays the potentially idle seats
14 changes: 6 additions & 8 deletions github_copilot_seats/autokitteh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ version: v1
project:
name: github_copilot_seats
vars:
- name: GITHUB_ORG
value: autokitteh
- name: IDLE_USAGE_THRESHOLD
value: 10 # 72 hours
- # If not empty, only manage GitHub Copilot subscriptions to the specified users, separated by commas.
name: LOGINS
- name: IDLE_HOURS_THRESHOLD
value: 72
- # Optional: manage GitHub Copilot subscriptions only for these users, separated by commas.
name: MANAGED_LOGINS
value: ""
- name: LOG_CHANNEL
value: log
- name: SLACK_LOG_CHANNEL
value: copilot-log
connections:
- name: github_conn
integration: github
Expand Down
53 changes: 0 additions & 53 deletions github_copilot_seats/helpers.py

This file was deleted.

86 changes: 42 additions & 44 deletions github_copilot_seats/msg.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "You have been removed from the Copilot program due to inactivity",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Please select an option:"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": ":repeat: Reinstate",
"emoji": true
},
"value": "reinstate",
"action_id": "reinstate-action"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": ":relieved: OK",
"emoji": true
},
"value": "ok",
"action_id": "ok-action"
}
]
}
]
}
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "You have been removed from the Copilot program due to inactivity",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Please select an option:"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": ":repeat: Reinstate",
"emoji": true
},
"value": "reinstate",
"action_id": "reinstate-action"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": ":relieved: OK",
"emoji": true
},
"value": "ok",
"action_id": "ok-action"
}
]
}
]
Loading

0 comments on commit 3913c22

Please sign in to comment.