Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# GitHub API Scripts

Standalone automation scripts for administering GitHub organizations and enterprises, including Copilot billing.

## Copilot budgets

**AI credit budget**:
A dollar-denominated monthly spending limit on Copilot AI credits, enforced by blocking further usage once reached.
_Avoid_: Quota, cap

**Universal budget**:
The AI credit budget that applies to every user in an enterprise unless overridden.
_Avoid_: Default budget, global budget

**User budget**:
An AI credit budget set for one individual user that overrides the universal budget for that user.
_Avoid_: Override, personal budget

**Effective budget**:
The AI credit budget that currently applies to a user, whether universal or user-specific.
_Avoid_: Current limit

**Budget increase**:
Raising a user's effective budget by a dollar amount, or to an absolute dollar amount.
_Avoid_: Top-up, bump
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Each script is a self-contained utility designed for a specific task. Navigate t
### Folder Layout (Domain-Based)

- `org-admin/`: `github-add-repo-collaborators-by-pattern`, `github-add-repo-permissions`, `github-archive-old-repos`, `github-auto-repo-creation`, `github-close-archived-repo-security-alerts`, `github-enable-issues`, `github-get-repo-list`, `github-import-repo`, `github-migrate-internal-repos-to-private`, `github-repo-from-template`
- `enterprise/`: `github-add-enterprise-team-read-permissions`, `github-dockerfile-discovery`, `github-get-consumed-licenses`, `github-get-public-repos`, `github-install-enterprise-app`
- `enterprise/`: `github-add-enterprise-team-read-permissions`, `github-dockerfile-discovery`, `github-get-consumed-licenses`, `github-get-public-repos`, `github-increase-copilot-user-budget`, `github-install-enterprise-app`
- `reporting/`: `github-monthly-issues-report`, `github-repo-permissions-report`, `github-copilot-report`, `github-copilot-budget-advisor`
- `personal/`: `github-organize-stars`

Expand Down Expand Up @@ -742,6 +742,48 @@ Total seats purchased: 200

---

### Increase Copilot User Budget

**Script:** `enterprise/github-increase-copilot-user-budget/github-increase-copilot-user-budget.sh`

Raises the Copilot AI credit budget for one enterprise user. The script shows the user's effective budget and consumption, then offers +$50, +$100, +$150, +$200 and +$250 presets, a custom increase, or an absolute amount. After confirmation it updates the user's own AI credit budget, or creates one when the user is only covered by the Universal budget.

**Required variables:**
```bash
export GITHUB_ENTERPRISE="your-enterprise-slug"

# GitHub auth — use one of:
export GITHUB_TOKEN=ghp_yourtoken # PAT with manage_billing:enterprise scope
# OR: token is resolved automatically from an active gh auth session with the required scope
```

**Usage:**
```bash
cd enterprise/github-increase-copilot-user-budget

./github-increase-copilot-user-budget.sh -u octocat
./github-increase-copilot-user-budget.sh -u octocat --increase 100 --expires 2026-12-31 -y
./github-increase-copilot-user-budget.sh -u octocat --amount 400 --dry-run
```

**Options:**

| Flag | Description | Default |
|------|-------------|---------|
| `-e, --enterprise SLUG` | GitHub Enterprise slug (or `$GITHUB_ENTERPRISE`) | — |
| `-u, --user LOGIN` | GitHub username to update (or `$TARGET_USER`); prompted if omitted | — |
| `--increase N` | Raise the limit by N whole dollars, skipping the menu | — |
| `--amount N` | Set the limit to N whole dollars, skipping the menu | — |
| `--expires DATE` | Expire the user budget on `YYYY-MM-DD` | none |
| `--allow-decrease` | Permit a new limit at or below the current limit | off |
| `--dry-run` | Show the planned change without applying it | off |
| `-y, --yes` | Skip the confirmation prompt | off |

> [!NOTE]
> Limits are whole dollars. Without `--increase` or `--amount`, prompts require a terminal. An ambiguous match (more than one AI credit budget for the user) aborts without changes.

---

### Install Enterprise App

**Script:** `enterprise/github-install-enterprise-app/github-install-enterprise-app.sh`
Expand Down Expand Up @@ -1016,6 +1058,7 @@ Each script is published as a **composite action**, so you can reference it dire
| `enterprise/github-add-enterprise-team-read-permissions` | Grant read permissions to an enterprise team across all orgs |
| `enterprise/github-dockerfile-discovery` | Discover Dockerfiles and extract `FROM` instructions across all enterprise orgs |
| `enterprise/github-get-consumed-licenses` | Report Enterprise consumed licence seat counts |
| `enterprise/github-increase-copilot-user-budget` | Raise the Copilot AI credit budget for a single enterprise user |
| `enterprise/github-get-public-repos` | List all public repositories across all Enterprise orgs |
| `enterprise/github-install-enterprise-app` | Install an enterprise-owned GitHub App into an org (JWT flow) |
| `org-admin/github-add-repo-collaborators-by-pattern` | Add collaborators to repositories matching a name pattern |
Expand Down
59 changes: 59 additions & 0 deletions enterprise/github-increase-copilot-user-budget/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 'Increase Copilot User Budget'
description: 'Raise the GitHub Copilot AI credit budget for a single enterprise user'
inputs:
github-token:
description: 'PAT with manage_billing:enterprise scope. Cannot be the built-in GITHUB_TOKEN.'
required: true
enterprise:
description: 'GitHub Enterprise slug'
required: true
user:
description: 'GitHub username whose budget is raised'
required: true
increase:
description: 'Whole dollars to add to the current limit (use this or amount)'
required: false
default: ''
amount:
description: 'Absolute new limit in whole dollars (use this or increase)'
required: false
default: ''
expires:
description: 'Optional expiry date for the user budget (YYYY-MM-DD)'
required: false
default: ''
allow-decrease:
description: 'Permit a new limit at or below the current limit'
required: false
default: 'false'
dry-run:
description: 'Show the planned change without applying it'
required: false
default: 'false'
api-url-prefix:
description: 'GitHub API base URL'
required: false
default: 'https://api.github.com'
runs:
using: composite
steps:
- name: Increase Copilot user budget
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
GITHUB_ENTERPRISE: ${{ inputs.enterprise }}
TARGET_USER: ${{ inputs.user }}
API_URL_PREFIX: ${{ inputs.api-url-prefix }}
INPUT_INCREASE: ${{ inputs.increase }}
INPUT_AMOUNT: ${{ inputs.amount }}
INPUT_EXPIRES: ${{ inputs.expires }}
INPUT_ALLOW_DECREASE: ${{ inputs.allow-decrease }}
INPUT_DRY_RUN: ${{ inputs.dry-run }}
run: |
ARGS=(--yes)
[[ -n "${INPUT_INCREASE}" ]] && ARGS+=(--increase "${INPUT_INCREASE}")
[[ -n "${INPUT_AMOUNT}" ]] && ARGS+=(--amount "${INPUT_AMOUNT}")
[[ -n "${INPUT_EXPIRES}" ]] && ARGS+=(--expires "${INPUT_EXPIRES}")
[[ "${INPUT_ALLOW_DECREASE}" == "true" ]] && ARGS+=(--allow-decrease)
[[ "${INPUT_DRY_RUN}" == "true" ]] && ARGS+=(--dry-run)
"${{ github.action_path }}/github-increase-copilot-user-budget.sh" "${ARGS[@]}"
Loading
Loading