This script uses the Github API to create invitations to a Github organization (e.g. "eecs280staff") and a single team (e.g. "Course Staff"). Users to invite are specified by a list of emails in a JSON file (any users that are already a member of the organization will be ignored).
Ensure you have node installed:
sudo apt update
sudo apt install nodejsOR
brew install nodejsIf you already have node, make sure you have a somewhat recent version:
node --versionFrom the base directory of this repo, install dependencies using npm:
npm installA post-install script will create template .env and emails.json files.
Edit the .env file. Make sure spaces are escaped or enclosed in quotes. For example:
GITHUB_TOKEN=your_github_token_here
ORGANIZATION_NAME=eecs280staff
TEAM_NAME="Course Staff"Consider generating a new token with a short lifetime for this purpose.
See https://github.com/settings/tokens.
Either a fine-grained token with Administration privileges or a classic token
with admin:org scope will work. Using an existing, long-lived token is not
recommended.
Edit the emails.json file to include the list of emails to invite. For example:
[
"uniqname1@umich.edu",
"uniqname2@umich.edu",
"uniqname3@umich.edu"
]The script checks if a user is already a member of the organization before sending an invite, so it's fine to include emails that may already be members.
Double check your configuration in .env and emails.json, then run:
npx tsx invite-users.ts