You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a JSON file that is an array of GitHub usernames, a --build feature could create the users.json file. Here is an example of that JSON array of usernames.
[
"github-username-1",
"github-username-2"
]
It will need a GITHUB_AUTH_TOKEN environment variable defined in order to create the GitHub-specific email addresses for the users (way better than what the README currently describes). Here is some code that is very close to what we currently use outside of git-iam to automatically create the users.json file.
/* eslint-disable no-console */constfs=require('fs')const{ Octokit }=require('@octokit/rest')conststudents=['student-github-username-1','student-github-username-2']constauthToken=process.env.GITHUB_AUTH_TOKENif(!authToken){console.error('Could not find your GitHub Personal Access Token in GITHUB_AUTH_TOKEN')console.info('You can proceed after you complete that step.')process.exit(1)}constgithub=newOctokit({auth: authToken})Promise.all(usernames.sort().map(username=>github.users.getByUsername({ username }))).then(results=>{/* eslint-disable camelcase */constuserData=results.map(result=>{constuser=result.dataconstid=user.idconstusername=user.loginconstname=user.name||user.loginconstcreated_at=user.created_atconstemail=user.id+'+'+user.login+'@users.noreply.github.com'return{ id, name, username, email, created_at }}).reduce((userObj,user)=>{userObj[user.username.toLowerCase()]=userreturnuserObj},{})fs.writeFile('users.json',JSON.stringify(userData,null,2),'utf8',console.log)console.log(userData)}).catch(err=>{console.error(err)})
The text was updated successfully, but these errors were encountered:
Better yet, if instead of an array of usernames we used objects that defined the user's name and their GitHub username, we can set the correct name of the user. This would let the user git iam my-first-name instead of git iam github-username. Obviously, we wouldn't be able to have two users with the same name though. Here is what the array could look like.
Given a JSON file that is an array of GitHub usernames, a
--build
feature could create the users.json file. Here is an example of that JSON array of usernames.It will need a
GITHUB_AUTH_TOKEN
environment variable defined in order to create the GitHub-specific email addresses for the users (way better than what the README currently describes). Here is some code that is very close to what we currently use outside of git-iam to automatically create the users.json file.The text was updated successfully, but these errors were encountered: