- Notifications
You must be signed in to change notification settings - Fork647
Better GitHub statistics images for your profile, with stats from private repos too
License
jstrieb/github-stats
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Generate visualizations of GitHub user and repository statistics with GitHubActions. Visualizations can include data for both private repositories, and forrepositories you have contributed to, but do not own.
Generated images automatically switch between GitHub light theme and GitHubdark theme.
When someone views a profile on GitHub, it is often because they are curiousabout a user's open source projects and contributions. Unfortunately, thatuser's stars, forks, and pinned repositories do not necessarily reflect thecontributions they make to private repositories. The data likewise does notpresent a complete picture of the user's total contributions beyond the currentyear.
This project aims to collect a variety of profile and repository statisticsusing the GitHub API. It then generates images that can be displayed inrepository READMEs, or in a user'sProfileREADME.
Since the project runs on GitHub Actions, no server is required to regularlyregenerate the images with updated statistics. Likewise, since the user runsthe analysis code themselves via GitHub Actions, they can use their GitHubaccess token to collect statistics on private repositories that an externalservice would be unable to access.
If the project is used with an access token that has sufficient permissions toread private repositories, it may leak details about those repositories inerror messages. For example, theaiohttp
library—used for asynchronous APIrequests—may include the requested URL in exceptions, which can leak the nameof private repositories. If there is an exception caused byaiohttp
, thisexception will be viewable in the Actions tab of the repository fork, andanyone may be able to see the name of one or more private repositories.
Due to some issues with the GitHub statistics API, there are some situationswhere it returns inaccurate results. Specifically, the repository view countstatistics and total lines of code modified are probably somewhat inaccurate.Unexpectedly, these values will become more accurate over time as GitHubcaches statistics for your repositories. Additionally, repositories that werelast contributed to more than a year ago may not be included in the statisticsdue to limitations in the results returned by the API.
For more information on inaccuracies, see issue#2,#3, and#13.
- Create a personal access token (not the default GitHub Actions token) usingthe instructionshere.Personal access token must have permissions:
read:user
andrepo
. Copythe access token when it is generated – if you lose it, you will have toregenerate the token.- Some users are reporting that it can take a few minutes for the personalaccess token to work. For more, see#30.
- Create a copy of this repository by clickinghere. Note: this isnot the same as forking a copy because it copies everything fresh,without the huge commit history.
- Go to the "Secrets" page of your copy of the repository. If this is theREADME of your copy, clickthis link to goto the "Secrets" page. Otherwise, go to the "Settings" tab of thenewly-created repository and go to the "Secrets" page (bottom left).
- Create a new secret with the name
ACCESS_TOKEN
and paste the copiedpersonal access token as the value. - It is possible to change the type of statistics reported by adding otherrepository secrets.
- To ignore certain repos, add them (in owner/name format e.g.,
jstrieb/github-stats
) separated by commas to a new secret—created asbefore—calledEXCLUDED
. - To ignore certain languages, add them (separated by commas) to a newsecret called
EXCLUDED_LANGS
. For example, to exclude HTML and TeX youcould set the value tohtml,tex
. - To show statistics only for "owned" repositories and not forks withcontributions, add an environment variable (under the
env
header in themainworkflow)calledEXCLUDE_FORKED_REPOS
with a value oftrue
. - These other values are added as secrets by default to prevent leakinginformation about private repositories. If you're not worried about that,you can change the values directlyin the Actions workflowitself.
- To ignore certain repos, add them (in owner/name format e.g.,
- Go to theActionsPage and press "RunWorkflow" on the right side of the screen to generate images for the firsttime.
- The images will be automatically regenerated every 24 hours, but they canbe regenerated manually by running the workflow this way.
- Take a look at the images that have been created in the
generated
folder. - To add your statistics to your GitHub Profile README, copy and paste thefollowing lines of code into your markdown content. Change the
username
value to your GitHub username.

- Link back to this repository so that others can generate their ownstatistics images.
- Star this repo if you like it!
There are a few things you can do to support the project:
- Star the repository (and follow me on GitHub for more)
- Share and upvote on sites like Twitter, Reddit, and Hacker News
- Report any bugs, glitches, or errors that you find
These things motivate me to keep sharing what I build, and they providevalidation that my work is appreciated! They also help me improve theproject. Thanks in advance!
If you are insistent on spending money to show your support, I encourage you toinstead make a generous donation to one of the following organizations. By advocatingfor Internet freedoms, organizations like these help me to feel comfortablereleasing work publicly on the Web.
- Inspired by a desire to improve uponanuraghazra/github-readme-stats
- Makes use ofGitHub Octicons to preciselymatch the GitHub UI
About
Better GitHub statistics images for your profile, with stats from private repos too