Skip to content

Commit a39c3f8

Browse files
committed
moving relevant scripts to gh cli folder
1 parent ffe0201 commit a39c3f8

13 files changed

+118
-118
lines changed

Diff for: gh-cli/README.md

+114-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ Adds a status check to the branch protection status check contexts.
3535

3636
See the [docs](https://docs.github.com/en/rest/branches/branch-protection?apiVersion=2022-11-28#add-status-check-contexts) for more information.
3737

38+
## add-codeowners-file-to-repositories.sh
39+
40+
Adds a `CODEOWNERS` file to a list of repositories.
41+
42+
1. Run: `./generate-repositories-list.sh <org> > repos.csv`
43+
- Or create a list of repos in a csv file, 1 per line, with a trailing empty line at the end of the file
44+
2. Run: `./add-codeowners-file-to-repositories.sh repos.csv ./CODEOWNERS false`
45+
- For the 3rd argument, pass `true` if you want to overwrite existing file, otherwise it appends to existing
46+
47+
> **Note**
48+
> This is currently only checking for CODEOWNERS files in the root
49+
3850
## add-collaborator-to-repository.sh
3951

4052
Adds a user with a specified role to a repository. Used in the `./copy-permissions-between-org-repos.sh` script.
@@ -43,6 +55,15 @@ Adds a user with a specified role to a repository. Used in the `./copy-permissio
4355

4456
Adds a user from an Enterprise into an org. See: [Documentation](https://docs.github.com/en/graphql/reference/mutations#addenterpriseorganizationmember)
4557

58+
## add-gitignore-file-to-repositories.sh
59+
60+
Adds a `.gitignore` file to a list of repositories.
61+
62+
1. Run: `./generate-repositories-list.sh <org> > repos.csv`
63+
- Or create a list of repos in a csv file, 1 per line, with a trailing empty line at the end of the file
64+
2. Run: `./add-gitignore-file-to-repositories.sh repos.csv ./.gitignore false`
65+
- For the 3rd argument, pass `true` if you want to overwrite existing file, otherwise it appends to existing
66+
4667
## add-ip-allow-list.sh
4768

4869
Adds an IP to an enterprise's or organization's [IP allow list](https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization).
@@ -59,6 +80,22 @@ Adds a team to a repository with a given permission level
5980

6081
Adds (invites) a user to an organization team
6182

83+
## add-users-to-team-from-list.sh
84+
85+
Invites users to a GitHub team from a list.
86+
87+
1. Create a new csv file with the users you want to add, 1 per line
88+
2. Make sure to leave a trailing line at the end of the csv
89+
3. Run: `./add-users-to-team-from-list.sh users.csv <org> <team>`
90+
91+
Example input file:
92+
93+
```csv
94+
joshjohanning
95+
FluffyCarlton
96+
97+
```
98+
6299
## change-repository-visibility.sh
63100

64101
Change a repository visibility to internal, for example
@@ -67,9 +104,32 @@ Change a repository visibility to internal, for example
67104

68105
Creates an enterprise organization - you just need to pass in the enterprise ID (obtained [via](./get-enterprise-id.sh)) along with billing email, admin logins, and organization name
69106

107+
## create-enterprise-organizations-from-list.sh
108+
109+
Creates organizations in an enterprise from a CSV input list (`orgs-to-create.csv`)
110+
70111
## create-organization-webhook.sh
71112

72-
Creates an organization webhook, with a secret, with some help from `jq`.
113+
Creates an organization webhook, with a secret, with some help from `jq`
114+
115+
## create-teams-from-list.sh
116+
117+
Loops through a list of teams and creates them.
118+
119+
1. Create a list of teams in a csv file, 1 per line, with a trailing empty line at the end of the file
120+
- Child teams should have a slash in the name, e.g. `test1-team/test1-1-team`
121+
- Build out the parent structure in the input file before creating the child teams; e.g. have the `test1-team` come before `test1-team/test1-1-team` in the file
122+
2. Run: `./create-teams-from-list.sh teams.csv <org>`
123+
124+
Example input file:
125+
126+
```csv
127+
test11-team
128+
test22-team
129+
test11-team/test11111-team
130+
test11-team/test11111-team/textxxx-team
131+
132+
```
73133

74134
## create-repository-from-template.sh
75135

@@ -146,6 +206,15 @@ If the variable already exists on the target organization it will be updated.
146206

147207
Deletes a release from a repository - need the [ID](#get-releasessh) of the release
148208

209+
## delete-repos-from-list.sh
210+
211+
Deletes a list of repositories.
212+
213+
1. Run: `./generate-repositories-list.sh <org> > repos.csv`
214+
2. Clean up the `repos.csv` file and remove the repos you **don't want to delete**
215+
3. Run `./delete-repositories-from-list.sh repos.csv`
216+
4. If you need to restore, [you have 90 days to restore](https://docs.github.com/en/repositories/creating-and-managing-repositories/restoring-a-deleted-repository)
217+
149218
## delete-repository.sh
150219

151220
Deletes a repo - also works if the repository is locked from a failed migration, etc.
@@ -162,6 +231,25 @@ Deletes all webhooks from a repository.
162231

163232
> **Warning** This operation is not reversible.
164233
234+
## delete-teams-from-list.sh
235+
236+
Loops through a list of teams and deletes them.
237+
238+
1. Create a list of teams in a csv file, 1 per line, with a trailing empty line at the end of the file
239+
- Child teams should have a slash in the name, e.g. `test1-team/test1-1-team`
240+
- `!!! Important !!!` Note that if a team has child teams, all of the child teams will be deleted as well
241+
2. Run: `./delete-teams-from-list.sh teams.csv <org>`
242+
243+
Example input file:
244+
245+
```csv
246+
test11-team
247+
test22-team
248+
test11-team/test11111-team
249+
test11-team/test11111-team/textxxx-team
250+
251+
```
252+
165253
## download-private-release-artifact.sh
166254

167255
Downloads a release artifact from a private/internal repository. Can either download latest version or specific version, and supports file pattern matching to download one or multiple files. See [docs](https://cli.github.com/manual/gh_release_download) for more info.
@@ -178,6 +266,20 @@ Enable actions on repository - similar to [API example](./../api/enable-actions-
178266

179267
Generates release notes between two tags. See the [release notes docs](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) on further customizations and the [API docs](https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#generate-release-notes-content-for-a-release) for info on the API.
180268

269+
## generate-repositories-list.sh
270+
271+
Generates a list of repos in the organization - has many uses, but the exported repos can be used in the `delete-repos-from-list.sh` script.
272+
273+
Credits to @tspascoal from this repo: https://github.com/tspascoal/dependabot-alerts-helper
274+
275+
1. Run: `./generate-repositories.sh <org> > repos.csv`
276+
277+
## generate-users-from-team.sh
278+
279+
Generates a list of users from a team in the organization - has many uses, but the exported users can be used in the `remove-users-from-org.sh` script.
280+
281+
1. Run: `./generate-users-from-team <org> <team> > users.csv`
282+
181283
## get-actions-permissions-on-repository.sh
182284

183285
Gets the status of Actions on a repository (ie, if Actions are disabled)
@@ -545,6 +647,13 @@ Removes an enterprise user. See notes:
545647

546648
Revokes an SSO-enabled PAT that a user created in an organization.
547649

650+
## remove-users-from-org.sh
651+
652+
Removes a list of users from the organization.
653+
654+
1. Create a list of users in a csv file, 1 per line, with a trailing empty line at the end of the file (or use `./generate-users-from-team <org> <team>`)
655+
2. Run: `./remove-users-from-org.sh <file> <org>`
656+
548657
## rename-repository.sh
549658

550659
Renaming a repo
@@ -574,3 +683,7 @@ Updates a branch protection rule for a given branch.
574683
## update-enterprise-owner-organizational-role.sh
575684

576685
Adds your account to an organization in an enterprise as an owner, member, or leave the organization.
686+
687+
## verify-team-membership.sh
688+
689+
Simple script to verify that a user is a member of a team

Diff for: scripts/add-codeowners-file-to-repositories.sh renamed to gh-cli/add-codeowners-file-to-repositories.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Adds a CODEOWNERS file to the default branch in a CSV list of repositories
44

55
# Usage:
6-
# Step 1: Run ./generate-repos.sh <org> > repos.csv
6+
# Step 1: Run ./generate-repositories-list.sh <org> > repos.csv
77
# - Or create a list of repos in a csv file, 1 per line, with a trailing empty line at the end of the file
88
# - DO NOT REMOVE TRAILING NEW LINE IN THE INPUT CSV FILE
99
# Step 2: ./add-codeowners-file-to-repositories.sh repos.csv ./CODEOWNERS false

Diff for: scripts/add-gitignore-file-to-repositories.sh renamed to gh-cli/add-gitignore-file-to-repositories.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Adds a .gitignore file to the default branch in a CSV list of repositories
44

55
# Usage:
6-
# Step 1: Run ./generate-repos.sh <org> > repos.csv
6+
# Step 1: Run ./generate-repositories-list.sh <org> > repos.csv
77
# - Or create a list of repos in a csv file, 1 per line, with a trailing empty line at the end of the file\
88
# - DO NOT REMOVE TRAILING NEW LINE IN THE INPUT CSV FILE
99
# Step 2: ./add-gitignore-file-to-repositories.sh repos.csv ./.gitignore false
File renamed without changes.
File renamed without changes.

Diff for: scripts/delete-repos-from-list.sh renamed to gh-cli/delete-repositories-from-list.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Need to run this to get the repo delete scope: gh auth refresh -h github.com -s delete_repo
66

77
# Usage:
8-
# Step 1: Run ./generate-repos.sh <org> > repos.csv
8+
# Step 1: Run ./generate-repositories-list.sh <org> > repos.csv
99
# - Or create a list of repos in a csv file, 1 per line, with a trailing empty line at the end of the file
1010
# - DO NOT REMOVE TRAILING NEW LINE IN THE INPUT CSV FILE
1111
# Step 2: ./delete-repos-from-list.sh repos.csv
File renamed without changes.

Diff for: scripts/generate-repos-list.sh renamed to gh-cli/generate-repositories-list.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Generates a list of repositories in an organization to a CSV file
44

5-
# Usage: ./generate-repos.sh <org> > csv.csv
5+
# Usage: ./generate-repositories-list.sh <org> > csv.csv
66

77
# Credits to @tspascoal from this repo: https://github.com/tspascoal/dependabot-alerts-helper
88

File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: scripts/README.md

-113
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,17 @@
11
# scripts
22

3-
## add-users-to-team-from-list.sh
4-
5-
Invites users to a GitHub team from a list.
6-
7-
1. Create a new csv file with the users you want to add, 1 per line
8-
2. Make sure to leave a trailing line at the end of the csv
9-
3. Run: `./add-users-to-team-from-list.sh users.csv <org> <team>`
10-
11-
Example input file:
12-
13-
```csv
14-
joshjohanning
15-
FluffyCarlton
16-
17-
```
18-
193
## ado_workitems_to_github_issues.ps1
204

215
Migrate work items from Azure DevOps to GitHub issues - this just links out to a [separate repo](https://github.com/joshjohanning/ado_workitems_to_github_issues)
226

23-
## add-codeowners-file-to-repositories.sh
24-
25-
Adds a `CODEOWNERS` file to a list of repositories.
26-
27-
1. Run: `./generate-repos.sh <org> > repos.csv`
28-
- Or create a list of repos in a csv file, 1 per line, with a trailing empty line at the end of the file
29-
2. Run: `./add-codeowners-file-to-repositories.sh repos.csv ./CODEOWNERS false`
30-
- For the 3rd argument, pass `true` if you want to overwrite existing file, otherwise it appends to existing
31-
32-
> **Note**
33-
> This is currently only checking for CODEOWNERS files in the root
34-
35-
## add-gitignore-file-to-repositories.sh
36-
37-
Adds a `.gitignore` file to a list of repositories.
38-
39-
1. Run: `./generate-repos.sh <org> > repos.csv`
40-
- Or create a list of repos in a csv file, 1 per line, with a trailing empty line at the end of the file
41-
2. Run: `./add-gitignore-file-to-repositories.sh repos.csv ./.gitignore false`
42-
- For the 3rd argument, pass `true` if you want to overwrite existing file, otherwise it appends to existing
43-
44-
## create-enterprise-organizations.sh
45-
46-
Loops through a list of orgs and creates them.
47-
48-
## create-teams-from-list.sh
49-
50-
Loops through a list of teams and creates them.
51-
52-
1. Create a list of teams in a csv file, 1 per line, with a trailing empty line at the end of the file
53-
- Child teams should have a slash in the name, e.g. `test1-team/test1-1-team`
54-
- Build out the parent structure in the input file before creating the child teams; e.g. have the `test1-team` come before `test1-team/test1-1-team` in the file
55-
2. Run: `./create-teams-from-list.sh teams.csv <org>`
56-
57-
Example input file:
58-
59-
```csv
60-
test11-team
61-
test22-team
62-
test11-team/test11111-team
63-
test11-team/test11111-team/textxxx-team
64-
65-
```
66-
677
## delete-branch-protection-rules.ps1
688

699
Delete branch protection rules programmatically based on a pattern.
7010

71-
## delete-repos-from-list.sh
72-
73-
Deletes a list of repositories.
74-
75-
1. Run: `./generate-repos-list.sh <org> > repos.csv`
76-
2. Clean up the `repos.csv` file and remove the repos you **don't want to delete**
77-
3. Run `./delete-repos-from-list.sh repos.csv`
78-
4. If you need to restore, [you have 90 days to restore](https://docs.github.com/en/repositories/creating-and-managing-repositories/restoring-a-deleted-repository)
79-
80-
## delete-teams-from-list.sh
81-
82-
Loops through a list of teams and deletes them.
83-
84-
1. Create a list of teams in a csv file, 1 per line, with a trailing empty line at the end of the file
85-
- Child teams should have a slash in the name, e.g. `test1-team/test1-1-team`
86-
- `!!! Important !!!` Note that if a team has child teams, all of the child teams will be deleted as well
87-
2. Run: `./delete-teams-from-list.sh teams.csv <org>`
88-
89-
Example input file:
90-
91-
```csv
92-
test11-team
93-
test22-team
94-
test11-team/test11111-team
95-
test11-team/test11111-team/textxxx-team
96-
97-
```
98-
9911
## gei-clean-up-azure-storage-account.sh
10012

10113
Clean up Azure Storage Account Containers from GEI migrations.
10214

103-
## generate-repos-list.sh
104-
105-
Generates a list of repos in the organization - has many uses, but the exported repos can be used in the `delete-repos-from-list.sh` script.
106-
107-
Credits to @tspascoal from this repo: https://github.com/tspascoal/dependabot-alerts-helper
108-
109-
1. Run: `./generate-repos.sh <org> > repos.csv`
110-
111-
## generate-users-from-team.sh
112-
113-
Generates a list of users from a team in the organization - has many uses, but the exported users can be used in the `remove-users-from-org.sh` script.
114-
115-
1. Run: `./generate-users-from-team <org> <team> > users.csv`
116-
11715
## get-app-jwt.py
11816

11917
This script will generate a JWT for a GitHub App. It will use the private key and app ID from the GitHub App's settings page.
@@ -165,17 +63,6 @@ Migrate NPM packages in GitHub Packages from one GitHub organization to another.
16563
2. Define the target GitHub PAT env var: export GH_TARGET_PAT=ghp_abc (must have at least `write:packages`, `read:org` scope)
16664
3. Run: `./migrate-npm-packages-between-github-instances.sh joshjohanning-org github.com joshjohanning-emu github.com`
16765

168-
## remove-users-from-org.sh
169-
170-
Removes a list of users from the organization.
171-
172-
1. Create a list of users in a csv file, 1 per line, with a trailing empty line at the end of the file (or use `./generate-users-from-team <org> <team>`)
173-
2. Run: `./remove-users-from-org.sh <file> <org>`
174-
17566
## update-repo-visibility-from-server-to-cloud.ps1
17667

17768
Compares the repo visibility of a repo in GitHub Enterprise Server and update the visibility in GitHub Enterprise Cloud. This is useful since migrated repos are always brought into cloud as private.
178-
179-
## verify-team-membership.sh
180-
181-
Simple script to verify that a user is a member of a team

0 commit comments

Comments
 (0)