-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GitHub script2.0 #96
Open
a544266477
wants to merge
22
commits into
saasbook:main
Choose a base branch
from
a544266477:github-script2.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
GitHub script2.0 #96
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9aabb17
Update script 2.0 read me
a544266477 dd1f730
finish invite
a544266477 058a873
finished script 2.0 need debug
a544266477 1c3f9c0
finished testing
a544266477 d0be6aa
change to use username to add students
a544266477 9e220d8
fix the indiv_repos child team loop
a544266477 5fcfe4b
add remove team repo access command
a544266477 452d647
Delete team-test.csv
a544266477 00bb0e2
Update some typo errors
a544266477 59a341e
update the opts parse and readme file
a544266477 d4c05a1
update the readme file and corresponding opt descriptions.
a544266477 d3ccfbb
fix creating repos
a544266477 70eaf2c
Turn on the auto pagination
a544266477 6d36cdc
add showing progress on looping
a544266477 96ba812
Update the temporary function.
a544266477 5676c09
update commands' names and rescue exceptions in invite command
a544266477 8ea5107
Remove the ENV variable in script
a544266477 0795399
Check if repo exists before calling clone to avoid rate limit
a544266477 4feb1fd
correct code indent
a544266477 2026642
update remove function to remove all repos not just private repo
a544266477 21b3ced
add optional option to create public repos and set up the repo permis…
a544266477 978e057
bugs fixed
a544266477 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
ruby '3.2.2' | ||
ruby '< 3.0' | ||
|
||
gem 'octokit' | ||
gem 'csv' | ||
gem 'yaml' | ||
gem 'tqdm' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
addressable (2.8.4) | ||
public_suffix (>= 2.0.2, < 6.0) | ||
csv (3.2.6) | ||
faraday (2.7.5) | ||
faraday-net_http (>= 2.0, < 3.1) | ||
ruby2_keywords (>= 0.0.4) | ||
faraday-net_http (3.0.2) | ||
octokit (6.1.1) | ||
faraday (>= 1, < 3) | ||
sawyer (~> 0.9) | ||
public_suffix (5.0.1) | ||
ruby2_keywords (0.0.5) | ||
sawyer (0.9.2) | ||
addressable (>= 2.3.5) | ||
faraday (>= 0.17.3, < 3) | ||
yaml (0.2.1) | ||
|
||
PLATFORMS | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
csv | ||
octokit | ||
yaml | ||
|
||
RUBY VERSION | ||
ruby 3.2.2p53 | ||
|
||
BUNDLED WITH | ||
2.4.13 | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
addressable (2.8.5) | ||
public_suffix (>= 2.0.2, < 6.0) | ||
base64 (0.1.1) | ||
csv (3.2.7) | ||
faraday (2.7.11) | ||
base64 | ||
faraday-net_http (>= 2.0, < 3.1) | ||
ruby2_keywords (>= 0.0.4) | ||
faraday-net_http (3.0.2) | ||
octokit (4.25.1) | ||
faraday (>= 1, < 3) | ||
sawyer (~> 0.9) | ||
public_suffix (5.0.3) | ||
ruby2_keywords (0.0.5) | ||
sawyer (0.9.2) | ||
addressable (>= 2.3.5) | ||
faraday (>= 0.17.3, < 3) | ||
tqdm (0.4.1) | ||
|
||
PLATFORMS | ||
arm64-darwin-22 | ||
|
||
DEPENDENCIES | ||
csv | ||
octokit | ||
tqdm | ||
|
||
RUBY VERSION | ||
ruby 2.6.10p210 | ||
|
||
BUNDLED WITH | ||
2.4.19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,144 @@ | ||
# Bulk creation/deletion of many repos and cs169a-team | ||
# Bulk creation/deletion of many repos and student teams | ||
|
||
``` | ||
Usage: ./github-repos.rb [required options] [invite|repos|remove|remove_access] | ||
Usage: ./github-repos.rb [required options] [invite|create_groups|indiv_repos|group_repos|remove_indiv_repos|remove_group_repos|remove_teams|remove_group_repos_access] [optional options] | ||
|
||
GITHUB_ORG_API_KEY for the org must be set as an environment variable. | ||
|
||
'invite' invites students provided in .csv file and creates teams, 'repos' creates team repos, 'remove' remove students, repos, teams from the org | ||
|
||
It's safe to run multiple times. | ||
|
||
Required arguments: | ||
-c, --csv=CSVFILE CSV file containing at least "Team" and "Email" named columns | ||
-o, --orgname=ORGNAME The name of the org eg org_name | ||
-f, --filename=FILENAME The base filename for repos, eg "fa23-actionmap-04", actionmap is the base file name of the repo | ||
-p, --prefix=PREFIX Semester prefix, eg "fa23" create a repos prefix, "fa23-actionmap-04", etc. | ||
-t, --template=TEMPLATE The repo name within the org to use as template eg repo_name (Assume the repo own by org) | ||
-s, --studentteam=STUDENTTEAM The team name of all the students team | ||
-g, --gsiteam=GSITEAM The team name of all the staff team | ||
'invite': | ||
Create a team called STUDENTTEAM under the org and send invitations to students to the team. | ||
If STUDENTTEAM already exists, the script will resend invitation to students. | ||
|
||
If PREFIX is provided, it will assume the csv file contains "Group" column, and create groups(child teams) under | ||
the STUDENTTEAM, and invites them to groups. | ||
|
||
Required options: | ||
-c, --csv=CSVFILE CSV file containing at least "Username" named columns | ||
-s, --studentteam=STUDENTTEAM The team name for students' team | ||
-o, --orgname=ORGNAME The name of the org | ||
|
||
Optional options: | ||
-p, --prefix=PREFIX Semester prefix, eg fa23. If prefix is not provided, it will not create groups. | ||
|
||
'create_groups' | ||
Assuming students are in STUDENTTEAM, create groups for students for CHIP 10.5 and add them to corresponding groups. | ||
|
||
Required options: | ||
-c, --csv=CSVFILE CSV file containing at least "Group" and "Username" named columns | ||
-s, --studentteam=STUDENTTEAM The team name for students' team | ||
-p, --prefix=PREFIX Semester prefix, eg fa23. | ||
-o, --orgname=ORGNAME The name of the org | ||
|
||
'indiv_repos' | ||
Create CHIPS repos for each student in STUDENTTEAM. Repos' names are form like "[PREFIX]-[username]-[ASSIGNMENT]" | ||
[username] stands for the GitHub username. | ||
|
||
Required options: | ||
-o, --orgname=ORGNAME The name of the org | ||
-s, --studentteam=STUDENTTEAM The team name for students' team | ||
-p, --prefix=PREFIX Semester prefix, eg fa23. | ||
-t, --template=TEMPLATE The repo name within the org to use as template | ||
-g, --gsiteam=GSITEAM The team name of staff team | ||
-a, --assignment=ASSIGNMENT The assignment name | ||
|
||
Optional options: | ||
-perm, --permission=PERMISSION The permission of the created repos, can be 'pull', 'push', or 'admin'. Default: 'push' | ||
-u, --public A flag infering to create public repository, otherwise the new repo is private. | ||
|
||
'group_repos' | ||
Create repos for each group. Repos' names are form like "[PREFIX]-[ASSIGNMENT]-[GROUPNUM]" | ||
Make sure groups are formed before running this command. | ||
|
||
Required options: | ||
-o, --orgname=ORGNAME The name of the org | ||
-p, --prefix=PREFIX Semester prefix, eg fa23. | ||
-t, --template=TEMPLATE The repo name within the org to use as template | ||
-a, --assignment=ASSIGNMENT The assignment name. eg chip-10.5 | ||
-s, --studentteam=STUDENTTEAM The team name for students' team | ||
-g, --gsiteam=GSITEAM The team name of staff team | ||
|
||
Optional options: | ||
-perm, --permission=PERMISSION The permission of the created repos, can be 'pull', 'push', or 'admin'. Default: 'push' | ||
-u, --public A flag infering to create public repository, otherwise the new repo is private. | ||
|
||
'remove_indiv_repos' | ||
Delete all repos whose names are formed like "[PREFIX]-[username]-[ASSIGNMENT]". | ||
|
||
Required options: | ||
-o, --orgname=ORGNAME The name of the org | ||
-p, --prefix=PREFIX Semester prefix, eg fa23. | ||
-a, --assignment=ASSIGNMENT The assignment name. eg chip-10.5 | ||
|
||
'remove_group_repos' | ||
Delete all repos whose names are formed like "[PREFIX]-[ASSIGNMENT]-[GROUPNUM]". | ||
|
||
Required options: | ||
-o, --orgname=ORGNAME The name of the org | ||
-p, --prefix=PREFIX Semester prefix, eg fa23. | ||
-a, --assignment=ASSIGNMENT The assignment name. eg chip-10.5 | ||
|
||
'remove_teams' | ||
Remove all students and groups in STUDENTTEAM from the org. | ||
Remove STUDENTTEAM as well. | ||
|
||
Required options: | ||
-o, --orgname=ORGNAME The name of the org | ||
-p, --prefix=PREFIX Semester prefix, eg fa23. | ||
-s, --studentteam=STUDENTTEAM The team name for students' team | ||
|
||
'remove_group_repos_access' | ||
Remove group access to group repos that are formed like "[PREFIX]-[ASSIGNMENT]-[GROUPNUM]". | ||
|
||
Required options: | ||
-o, --orgname=ORGNAME The name of the org | ||
-p, --prefix=PREFIX Semester prefix, eg fa23. | ||
-a, --assignment=ASSIGNMENT The assignment name. eg chip-10.5 | ||
``` | ||
|
||
This script creates a team that include all stundents in the same semester, eg fa23. | ||
Then creates different child teams for them for the chip10.5. At a minimum, | ||
you need a CSV file listing all enrolled students with columns 'Email' and 'Team'. | ||
The values in the Team columns should be nonnegative integers identifying teams. | ||
This script offer commands to manage student teams and groups, repositories. | ||
|
||
Org setting: Assume Base permissions is no permission, each students can only access their team repos. | ||
|
||
**Assumption:** You have a GITHUB ORG API key. | ||
|
||
### Create a team under the org that includes all students in the same semester | ||
### Create a student team under the org and send invitations to students | ||
|
||
**Use case:** Create a team called STUDENTTEAM if it don't exist, and send invitations | ||
to the students in csv file. For students NOT in STUDENTTEAM, invite them to STUDENTTEAM. | ||
|
||
### Create groups for students for CHIP 10.5 | ||
|
||
**Use case:** Create groups for students for CHIP 10.5. | ||
|
||
### Create CHIPS repo for each student | ||
|
||
**Use case:** Create CHIP repos for each student in STUDENTTEAM. | ||
The repos' names are formed like "[PREFIX]-[username]-[ASSIGNMENT]". There will | ||
be only one collabrator. Give GSITEAM admin access to the created repos. | ||
|
||
### Create 10.5 repos for each group | ||
|
||
**Use case:** Each group (as identified by "Group" column in CSV file) | ||
gets a repo for chip 10.5. Repos' names are formed like "[PREFIX]-[ASSIGNMENT]-[TEAMNUM]" | ||
Every one in the same group has write access to the repo. | ||
Give GSITEAM admin access to the created repos. | ||
|
||
### Remove the CHIPS repos | ||
|
||
**Use case:** Create a team called STUDENTTEAM, and send invitations | ||
to the students in csv file. If STUDENTTEAM exists, delete the team and | ||
create a new one. (Team repos still exist) | ||
For all students NOT in that team, add/invite into that team. | ||
**Use case:** Delete all repos whose names are formed like "[PREFIX]-[username]-[ASSIGNMENT]". | ||
|
||
### Create 10.5 repos for each child team | ||
### Remove CHIP 10.5 repos | ||
|
||
**Use case:** Each team (as identified by Team column in CSV file) | ||
gets a repo for chip 10.5. Repos' names are formed | ||
by concatenating the prefix, base file name, and the team ID. | ||
(eg "fa23-actionmap-04" for team #4) For all students on that team who do | ||
NOT already have access to the repo, give them write access on the repo. | ||
Add all repos to the gsiteam with admin permission. | ||
**Use case:** Delete all repos whose names are formed like "[PREFIX]-[ASSIGNMENT]-[GROUPNUM]". | ||
|
||
### Remove all team members from students team, and delete all the repos | ||
### Remove all team members from students teams, then delete all teams | ||
|
||
**Use case:** Delete all repos whose name matches the "PREFIX-FILENAME-team number". | ||
Remove all students and subteams in STUDENTTEAM from the org. | ||
**Use case:** Remove all students and groups in STUDENTTEAM from the org. | ||
|
||
### Remove student access to all the chip 10.5 repos | ||
|
||
**Use case:** Only remove the access of students teams, repos still can be accessed by | ||
**Use case:** Only remove the access of students groups, repos can still be accessed by | ||
gsi team. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for optional options, you have to state what the default is if the option is not given