gh-accept-invites
v1.0.0
Published
Accept all pending GitHub repository invitations from a specific owner
Maintainers
Readme
gh-accept-invites
Accept all pending repository invitations from a specific owner. Zero runtime dependencies — uses native fetch.
Use case
You received repository invitations from a machine user account and want to accept them all at once. Perhaps someone used gh-invite-all to send hundreds of invitations — this tool lets you accept them in bulk.
Requirements
- Node.js >= 18
- A GitHub personal access token (PAT) — see below
Token setup
Classic PAT (recommended) — narrowest scope:
- Create a classic token
- Select only the
repo:invitescope - Export it:
export GITHUB_TOKEN="ghp_..."
Fine-grained PAT — requires broader permissions:
- Create a fine-grained token
- Grant Administration: Read and Write on target repositories
- Export it:
export GITHUB_TOKEN="github_pat_..."
Why classic? The
repo:invitescope grants access to invitations only. Fine-grained tokens have no equivalent — they require "Administration", which also covers repository settings, webhooks, environments, and more.
Install
npm install -g gh-accept-invitesUsage
export GITHUB_TOKEN="ghp_..."
# List all pending invitations
gh-accept-invites --list
# Accept all invitations from a specific owner
gh-accept-invites <owner>Output
List mode:
Pending invitations:
machine-user (3 invites)
repo-1
repo-2
repo-3
other-owner (1 invite)
some-repo
2 expired invitations not shown.Accept mode:
✓ machine-user/repo-1 — accepted
✓ machine-user/repo-2 — accepted
✗ machine-user/repo-3 — error: HTTP 403 Forbidden
Done. 2 accepted, 1 errors. 1 expired invitation skipped.Expired invitations (invitations past their 7-day GitHub expiry) are automatically filtered out. When expired invitations exist, the count is shown in the output.
API
The core logic is also available as a library:
import { acceptInvites, listInvites } from "gh-accept-invites";
// Accept all invitations from an owner
const { results, expiredCount } = await acceptInvites({
token: process.env.GITHUB_TOKEN!,
owner: "machine-user",
});
// List all pending invitations
const { invitations, expiredCount } = await listInvites({
token: process.env.GITHUB_TOKEN!,
});Each result has { repo, owner, status, error? } where status is one of:
"accepted"— invitation accepted"error"— failed (seeerrorfield)
Development
git clone <repo-url>
cd gh-accept-invites
npm install
npm run buildRun the CLI locally:
npm start -- <owner>Run tests:
npm testLicense
BSD 3-Clause. See LICENSE.
