Skip to content

Commit 7f661a9

Browse files
author
Patrick Lewis
committed
Add GitHub repository permissions and Copilot reports scripts with detailed usage instructions
1 parent 720f391 commit 7f661a9

3 files changed

Lines changed: 932 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Each script is a self-contained utility designed for a specific task. Navigate t
9393

9494
- `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`
9595
- `enterprise/`: `github-add-enterprise-team-read-permissions`, `github-dockerfile-discovery`, `github-get-consumed-licenses`, `github-get-public-repos`
96-
- `reporting/`: `github-monthly-issues-report`
96+
- `reporting/`: `github-monthly-issues-report`, `github-repo-permissions-report`, `github-copilot-report`
9797
- `personal/`: `github-organize-stars`
9898

9999
### Add Repository Permissions
@@ -236,6 +236,92 @@ cd reporting/github-monthly-issues-report
236236
237237
---
238238

239+
### Repository Permissions Report
240+
241+
**Script:** `reporting/github-repo-permissions-report/github-repo-permissions-report.sh`
242+
243+
Exports repository user/team permissions to CSV and identifies who can bypass pull request approval requirements, from both branch protection rules and repository rulesets.
244+
245+
**Prerequisites:**
246+
- **[gh](https://cli.github.com)** — GitHub CLI (authenticated via `gh auth login`)
247+
- **[jq](https://stedolan.github.io/jq)** — JSON processor
248+
249+
**Usage:**
250+
```bash
251+
cd reporting/github-repo-permissions-report
252+
./github-repo-permissions-report.sh -r OWNER/REPO
253+
./github-repo-permissions-report.sh -r OWNER/REPO -b main -o report.csv
254+
```
255+
256+
**Options:**
257+
258+
| Flag | Description | Default |
259+
|------|-------------|----------|
260+
| `-r, --repo OWNER/REPO` | Target repository (required) | — |
261+
| `-b, --branch NAME` | Branch to evaluate | Repository default branch |
262+
| `-o, --output FILE` | Output CSV path | `OWNER-REPO-permissions-BRANCH-YYYYMMDD.csv` |
263+
264+
**What it does:**
265+
- Fetches all collaborators and teams with repository access
266+
- Fetches branch protection rules and repository rulesets
267+
- Identifies every principal that can bypass PR approval requirements
268+
- Produces a CSV with two record types: `permission` (all users/teams) and `bypass_actor` (explicit bypass entries)
269+
270+
> [!NOTE]
271+
> Uses the `gh` CLI for all API calls. Authenticate via `gh auth login` before running.
272+
273+
---
274+
275+
### Copilot Enterprise Report
276+
277+
**Script:** `reporting/github-copilot-report/github-copilot-report.sh`
278+
279+
Generates a GitHub Copilot Enterprise licence and usage report. Shows every licensed user, their plan type, pool credit contribution, and actual AI credit consumption for the current billing month. Optionally enriches data with Entra ID department information.
280+
281+
**Prerequisites:**
282+
- **[gh](https://cli.github.com)** — GitHub CLI authenticated with `read:enterprise` and `manage_billing:enterprise` scopes
283+
- **[az](https://learn.microsoft.com/en-us/cli/azure/)** — Azure CLI (optional, for Entra ID department enrichment)
284+
- **[jq](https://stedolan.github.io/jq)** — JSON processor
285+
286+
**Required variables:**
287+
```bash
288+
export GITHUB_ENTERPRISE="your-enterprise-slug"
289+
290+
# Optional: Entra ID UPN domain for users without a public GitHub email
291+
export UPN_DOMAIN="example.com" # e.g. 'john_example' → john@example.com
292+
293+
# Optional: override the credits-per-seat value shown in your billing portal
294+
export CREDITS_PER_SEAT_OVERRIDE="1900"
295+
```
296+
297+
**Usage:**
298+
```bash
299+
cd reporting/github-copilot-report
300+
301+
# Authenticate first
302+
gh auth refresh --scopes "read:enterprise,manage_billing:enterprise"
303+
az login # optional, for department enrichment
304+
305+
./github-copilot-report.sh -e YOUR-ENTERPRISE
306+
./github-copilot-report.sh -e YOUR-ENTERPRISE -d example.com
307+
./github-copilot-report.sh -e YOUR-ENTERPRISE --no-entra
308+
```
309+
310+
**What it does:**
311+
- Fetches all Copilot seats across the enterprise (deduplicated by user)
312+
- Fetches per-user AI credit consumption for the current billing month
313+
- Fetches enterprise-level model usage metrics (last 28 days)
314+
- Optionally enriches each user with Entra ID department and job title via `az rest`
315+
- Outputs a CSV and a formatted console summary with department breakdown and model usage tables
316+
317+
> [!IMPORTANT]
318+
> Requires an enterprise owner or billing manager token. Run `gh auth refresh --scopes "read:enterprise,manage_billing:enterprise"` before executing.
319+
320+
> [!NOTE]
321+
> Uses the `gh` CLI and (optionally) the `az` CLI. The Entra ID enrichment is skipped automatically if `az` is not logged in, or can be disabled with `--no-entra`.
322+
323+
---
324+
239325
### Get Consumed Licenses
240326

241327
**Script:** `enterprise/github-get-consumed-licenses/github-get-consumed-licenses.sh`

0 commit comments

Comments
 (0)