gh-invite-all
v1.0.0
Published
Invite a collaborator to all repositories of a GitHub account
Maintainers
Readme
gh-invite-all
Invite a collaborator to all repositories owned by a GitHub account. Skips repos where the collaborator is already a member or has a pending invitation.
Zero runtime dependencies — uses native fetch.
Use case
You have a machine user account that owns several repositories and you want to invite your personal account as a collaborator to all of them — just run this tool and you're all set.
Requirements
- Node.js >= 18
- A fine-grained personal access token with:
- Metadata: Read
- Administration: Read and Write
Install
npm install -g gh-invite-allUsage
export GITHUB_TOKEN="ghp_..."
gh-invite-all <collaborator-username>Or with environment variables:
GITHUB_TOKEN="ghp_..." COLLABORATOR="username" npx gh-invite-allOutput
Inviting "username" to all repos...
✓ owner/repo-1 — invited
- owner/repo-2 — already a collaborator
- owner/repo-3 — invitation already pending
✗ owner/repo-4 — error: HTTP 403 Forbidden
Done. 1 invited, 2 skipped, 1 errors.API
The core logic is also available as a library:
import { inviteToAll } from "gh-invite-all";
const results = await inviteToAll({
token: process.env.GITHUB_TOKEN!,
collaborator: "username",
});Each result has { repo, owner, status, error? } where status is one of:
"invited"— invitation sent"skipped_collaborator"— already a collaborator"skipped_pending"— invitation already pending"error"— failed (seeerrorfield)
Development
git clone <repo-url>
cd gh-invite-all
npm install
npm run buildRun the CLI locally:
npm start -- <collaborator-username>Run tests:
npm testLicense
BSD 3-Clause. See LICENSE.
