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

gh-cli/README.md

Lines changed: 114 additions & 1 deletion
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

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

Lines changed: 1 addition & 1 deletion
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

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

Lines changed: 1 addition & 1 deletion
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.
File renamed without changes.

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

Lines changed: 1 addition & 1 deletion
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.

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

Lines changed: 1 addition & 1 deletion
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.

0 commit comments

Comments
 (0)