This repository is based on the GitHub platform sample code for finding inactive members, the original script can be found here: github/platform-samples.
This script queries the GitHub REST API to scan all members of the organisation. It checks for commits, issue creation, comments, and interactions with pull requests. These activities are compared to the specified cutoff date. Based on its findings it generates a simple CSV report, outputting both active and inactive members.
You need to make sure you have Ruby installed (and it's up-to-date), follow these steps:
Install ruby
brew install rubyAdd ruby to your path
echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrcRefresh the terminal configuration
source ~/.zshrc- Go to the developer settings in your GitHub account and the fine-grained tokens page.
- Click generate new fine-grained token.
- Under the resource owner, select the
organisationyou want to scan. - Configure the following read-only permissions:
- In the organisations tab:
members - In the repository tab:
contents,issues,metadataandpull requests.
- In the organisations tab:
- Generate the token, copy and save the token.
Navigate to the script directory
cd find-inactive-github-membersInstall the GitHub API client gem, perhaps with sudo
sudo gem install octokitAuthenticate your terminal session with your copied token, replace the <personal_access_token> string in the command
below:
export OCTOKIT_ACCESS_TOKEN="<personal_access_token>"To run the script, use the following command. Make sure to replace <organisation> with the name of your organisation
and adjust the cutoff date to whatever you want. This acts as a filter while querying data, so if you set it to
three months ago. It will only query/analyse the data of the past three months.
Beware that GitHub has a rate limit of 5000 requests per hour.
ruby find_inactive_users.rb -o <organisation> -d "2025-05-25"