Skip to content

Instantly share code, notes, and snippets.

@mchow01
Created February 17, 2018 04:01
Show Gist options
  • Save mchow01/af7ffacd91439ba5ab232a1a8343fbbe to your computer and use it in GitHub Desktop.
Save mchow01/af7ffacd91439ba5ab232a1a8343fbbe to your computer and use it in GitHub Desktop.
Create private GitHub repos for semester group project in COMP 20: Web Programming
require "csv"
require 'Octokit'
# See documentation at:
# 1. https://github.com/octokit/octokit.rb
# 2. http://www.rubydoc.info/github/pengwynn/octokit/Octokit
# Settings
# roster.tsv contains two columns separated by tab: username and team_number
roster_file_name = "roster.tsv"
github_org = "tuftsdev"
repo_description_prefix = "COMP 20 Spring 2018 Semester Group Project Repository"
num_teams = #NUM_TEAMS_HERE
begin
client = Octokit::Client.new(:access_token => #ACCESS_TOKEN_HERE)
1.upto(num_teams) do |team_number|
repo_name = "comp20-s2018-team" + team_number.to_s
repo = client.create_repository(repo_name, {
:description => "#{repo_description_prefix}",
:private => "true",
:team_id => #TEAM_ID_HERE,
:organization => github_org
})
# team_id is to give TA access
end
parsed_file = CSV.read(roster_file_name, { :col_sep => "\t" })
parsed_file.each do |student|
client.add_collaborator("#{github_org}/comp20-s2018-team#{student[1]}", student[0], permission: 'admin')
end
rescue IOError => e
puts "Whoops, something went terribly wrong! " + e.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment