Inspired by: Happy Git with R
You will need to manually create a github organization and a team for students. At a minimum, you will also need a list of your students github usernames.
A good template to follow can be found here.
You'll also want to create a github token with admin access to your org.
pkgs <- c("magrittr", "purrr", "gh", "dplyr", "glue")
install.packages(pkgs)
These scripts will:
- Create repos for each student
- Add students to student team
- Give student team read access to other student repos
- instructors should have push access by default if you set up the instructor team correctly
- Add each student as collaborator to org with push access to their own repo
- Unwatch student repos so you don't get notifications every time they push
Note: The following examples assume you've saved your github token in a plaintext file called 'auth.txt'
source("github_functions")
orgName <- "organization_name"
teamName <- "students_team_name"
auth <- readr::read_file("auth.txt") %>%
gsub("\n", "", .)
userNames <- c("testuser1", "testuser2")
This will create a repository named after each students' username. repoNames
below can be any list that is parallel to userNames
.
setup_course_repos(repoNames = userNames, userNames = userNames, orgName, teamName, auth)
Note: This defaults to making private repositories. This can be changed by passing private = F
.
Register your Org with Github as an academic organization for free private repos.
You can also disable auto-initialization with README with auto_init = F
.
Github will replace nonstandard characters like ' with - during creation, but if the character is present in your repo names vector, you'll get errors. Ensure your repo names vector only contains non-special characters.
purrr::map(userNames, ~{delete_student_repo(orgName, ., auth)})