Skip to content

JBScaled/OrgInviter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GitHub Organization Inviter

This Node.js script automates the process of inviting GitHub users to an organization based on a list of GitHub usernames.


πŸš€ Getting Started

1. Install Dependencies

Run the following command to install the required packages:

npm install

This script uses:

  • @octokit/rest@18 – GitHub REST API SDK (Classic, compatible with CommonJS)
  • dotenv – For loading environment variables

2. Set Up Your .env File

Create a .env file in the root directory and add the following:

GITHUB_TOKEN=your_personal_access_token
GITHUB_ORG=your_organization_name

3. Prepare Your GitHub Username List

Save your GitHub usernames in a file called github_usernames.json using the format:

[
  "username1",
  "username2",
  "username3"
]

4. Run the Script

To execute the script:

node inviteUsers.js

5. Review Failed Invites

Any invite failures (e.g., invalid usernames, rate limits) will be saved to:

failed_invites.json

You can use this file to retry the failed invites later.


πŸ›  Script Overview

The script performs the following actions:

  1. Loads the GitHub organization and token from .env
  2. Reads a list of usernames from github_usernames.json
  3. Attempts to invite each user via the GitHub API
  4. Logs successes to the console
  5. Writes any failures (with reasons) to failed_invites.json

🧠 Notes

  • GitHub enforces a rate limit of 50 invitations per 24 hours.
  • The script skips usernames that are invalid or already invited.
  • You can update the script to assign "admin" role instead of "member" if needed.

πŸ“ Example File Structure

.
β”œβ”€β”€ inviteUsers.js
β”œβ”€β”€ .env
β”œβ”€β”€ github_usernames.json
└── failed_invites.json  # Created automatically

πŸ“„ License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published