Skip to content

daviddallet/gh-accept-invites

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  1. Create a classic token
  2. Select only the repo:invite scope
  3. Export it: export GITHUB_TOKEN="ghp_..."

Fine-grained PAT — requires broader permissions:

  1. Create a fine-grained token
  2. Grant Administration: Read and Write on target repositories
  3. Export it: export GITHUB_TOKEN="github_pat_..."

Why classic? The repo:invite scope 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-invites

Usage

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 (see error field)

Development

git clone <repo-url>
cd gh-accept-invites
npm install
npm run build

Run the CLI locally:

npm start -- <owner>

Run tests:

npm test

License

BSD 3-Clause. See LICENSE.

Releases

No releases published

Packages

 
 
 

Contributors