You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 720f391
Browse filesBrowse the repository at this point in the historyBrowse files
- Implemented `github-enable-issues.sh` to enable issues on all repositories in an organization that currently have them disabled.
- Created `github-get-repo-list.sh` to fetch and list all repositories in a specified organization.
- Developed `github-import-repo.sh` for importing a repository from one name to another within the same organization.
- Added `github-migrate-internal-repos-to-private.sh` to convert internal repositories to private.
- Introduced `github-repo-from-template.sh` to create a new repository from a specified template and manage permissions.
- Created `github-organize-stars.sh` to fetch starred repositories and organize them into GitHub Lists based on predefined categories.
- Implemented `github-monthly-issues-report.sh` to generate a report of issues created within a specified date range, including authors and contributors.
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+7-136Lines changed: 7 additions & 136 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,30 +2,27 @@
2
2
3
3
## Project Overview
4
4
5
-
This is a collection of **standalone bash automation scripts** for GitHub organization and enterprise administration. Each script lives in its own directory with a single `.sh` file. Scripts use `curl` + `jq` to interact with the GitHub REST and GraphQL APIs. A shared utility library lives in `lib/github-common.sh`.
5
+
This is a collection of **standalone bash automation scripts** for GitHub organization and enterprise administration. Scripts are grouped by domain folders (`org-admin/`, `enterprise/`, `reporting/`, `personal/`), and each script lives in its own subdirectory with a single `.sh` file. Scripts use `curl` + `jq` to interact with the GitHub REST and GraphQL APIs. A shared utility library lives in `lib/github-common.sh`.
6
6
7
7
**Key principle:** Scripts are independent, self-contained utilities. Each script is a complete, self-validating executable that manages its own error handling and input validation. Scripts source `lib/github-common.sh` for shared validation and output helpers where applicable.
8
8
9
9
## Architecture Pattern
10
10
11
11
### Directory Structure
12
12
```
13
-
github-<script-name>/
14
-
└── github-<script-name>.sh # Single executable script
13
+
<domain>/
14
+
└── github-<script-name>/
15
+
└── github-<script-name>.sh # Single executable script
15
16
lib/
16
-
└── github-common.sh # Shared utility functions
17
+
└── github-common.sh # Shared utility functions
17
18
```
18
19
19
-
Each script follows this exact naming convention. Scripts are NOT imported or called by each other.
20
+
Each script follows the `github-<script-name>/github-<script-name>.sh` naming convention inside one domain folder. Scripts are NOT imported or called by each other.
- Use `${VARIABLE:-''}` for all env vars to provide empty defaults
56
-
- Set `API_URL_PREFIX` and `GIT_URL_PREFIX` for GitHub Enterprise Server compatibility
57
-
-**ALWAYS validate required variables** before any API calls — use `require_env_var` from lib or explicit `if [ -z "${VAR}" ]` checks
58
-
-**ALWAYS validate GITHUB_TOKEN** via `validate_github_token` (lib) or the `/user` endpoint pattern
59
-
- Use `curl -s -o /dev/null -w "%{http_code}"` pattern to check HTTP status codes
60
-
- Exit with status code 1 on validation failures with descriptive error messages
61
-
- Rate limiting delays vary by script: `sleep 5` for per-repo team operations, `sleep 2` for archive operations, `sleep 0.5` or `sleep 0.2` for lighter patch operations
62
52
63
53
## GitHub API Patterns
64
54
@@ -81,26 +71,13 @@ For enterprise-level org iteration (GraphQL), use cursor-based pagination — se
81
71
### Rate Limiting
82
72
83
73
Rate limiting delays are calibrated per operation type:
84
-
-**Per-repo team permission assignments:**`sleep 5` (see `github-add-repo-permissions.sh`, `github-repo-from-template.sh`)
85
-
-**Archive operations:**`sleep 2` (see `github-archive-old-repos.sh`)
86
-
-**Lightweight patch operations:**`sleep 0.5` (see `github-enable-issues.sh`) or `sleep 0.2` (see `github-close-archived-repo-security-alerts.sh`)
87
-
-**Code search + content fetch:** configurable `SEARCH_SLEEP` / `CONTENT_SLEEP` with exponential backoff (see `github-dockerfile-discovery.sh`, `github-get-public-repos.sh`)
88
74
89
75
### Authentication Headers
90
76
91
-
-`token` scheme for standard org/repo API: `-H "Authorization: token ${GITHUB_TOKEN}"`
92
-
-`Bearer` scheme for enterprise endpoints and GraphQL: `-H "Authorization: Bearer ${GITHUB_TOKEN}"`
93
-
- Some scripts use **both** (e.g., `github-dockerfile-discovery.sh`, `github-get-public-repos.sh`)
94
-
- Include API version when specified: `-H "X-GitHub-Api-Version: 2022-11-28"`
95
77
96
78
### Accept Headers (Media Types)
97
79
98
80
Different endpoints require specific Accept headers:
- At least one permission level variable must be set
140
-
- Uses pagination + `sleep 5` delay between repos
141
-
- Loops through teams with helper function `apply_team_permissions()`
142
104
143
105
### `github-archive-old-repos`
144
-
- Identifies repos not updated in the last N years (configurable via `YEARS_THRESHOLD`, default: `5`)
145
-
- Generates a timestamped CSV report in `reports/old_repos_${TIMESTAMP}.csv`
146
-
-**Interactive:** Prompts for confirmation before archiving; shows top 10 oldest repos first
147
-
- Skips already-archived repos; uses `sleep 2` between archive operations
148
-
- macOS (`date -v`) and Linux (`date -d`) compatible date arithmetic
149
106
150
107
### `github-auto-repo-creation`
151
-
- Creates repos with branch protection, a `CODEOWNERS` file, and team assignments
152
-
- Variables: `REPO_NAMES` (comma-separated), `REPO_OWNERS` (comma-separated team slugs with write), `ADMIN_TEAMS` (comma-separated team slugs with admin)
153
-
- Creates repos as `private: true`, with issues enabled, no projects or wiki
154
-
- Encodes CODEOWNERS content via `base64` for API upload
0 commit comments