This is a basic utility that can automatically accept repo invitations for github.
Node.js, tested on 14.x but should be fine on most modern versions
A Personal Access Token with repo:invite permissions. Get one at Github > Settings > Developer Settings > Personal Access Tokens and be sure to select repo:invite scopes before generation
- Clone the repo
git clone https://github.com/hi-ashleyj/accept-github-invitations.git
- Create a config.json file in the root directory and add a Personal Access Token with repo:invite scope
{
"access_token": "<YOUR_TOKEN_HERE>"
}
- Run with
node app.js
# or
npm start
or, if you want to pass in your access token instead, use
node app.js --token <YOUR_TOKEN_HERE>
In your config.json file, simply include an array of the users you wish to always deny
{
...other stuff,
"deny": [
"github",
"octocat"
]
}
If the users that you have specified own the repository, or invite you to it, the invitation will always decline
When in strict mode, only requests from allowed users will be accepted. All others will decline. To do this, add this to your config.json (without the comments)
{
...other stuff,
// First, enable strict mode
"strict": true,
// Then, allow only a few users
"allow": [
"octocat",
"hi-ashleyj"
]
}
If the users that you specifiy own the repository, or invite you to it, the invitation will automatically accept. This DOES NOT override denylist functionality, which will always take precendence. The allowlist makes no difference when strict: false
- Create your own copy of the repo (however you like to do this)
- Add a secret (Repo Settings > Secrets) called INVITE_ACCESS_TOKEN with your access token
- Execute the workflow run from the actions tab.
Feel free to use this basic script however you like, and modify it to add always-running or at-time based refreshing. I accept PRs and Issues on the base script, not on any modified versions.