If you work on private repositories and want those contributions (commits) to show up on your stats cards (like commit count, streak, top languages), you need to set up a Personal Access Token (PAT) and enable private contributions on your profile.
In order for your private commits to even count in your GitHub Contribution graph, you need to enable it in your profile settings:
- Open your GitHub profile (
https://github.com/your_username). - Scroll down to your green contribution graph.
- In the top right corner above the graph, click on "Contribution settings" (dropdown menu).
- Check the "Private contributions" option. (This will add your private repository commits to the graph without revealing the names of those repositories to others).
For this script to read data from your private repositories (to create accurate SVG stats), it needs token access.
- Go to the top right corner of GitHub (your profile picture) and click Settings.
- At the bottom of the left sidebar, click on Developer settings.
- Then go to Personal access tokens -> Tokens (classic).
- Click the Generate new token (classic) button.
- In the Note field, write whatever you want (e.g.,
PAT_STATS). - Under Expiration, it is recommended to set
No expiration(or a specific longer period, but you will have to renew it when it expires). - In the Select scopes section, make sure to check:
repo(this allows access to both public and private repositories).read:useranduser:email(under theusersection, to fetch user data).
- Scroll to the bottom of the page and click Generate token.
- Copy the generated token immediately because you won't be able to see it again after closing the page!
Now you must add that token to this repository so the GitHub Action script can use it.
- Open this repository on GitHub.
- Click on the Settings tab (repository settings).
- On the left side menu, go to Secrets and variables -> Actions.
- Click the green New repository secret button.
- In the Name field, you must type exactly the following:
PAT_STATS(this is how it's defined in the.github/workflows/update-stats.ymlfile). - In the Secret field, paste your copied token from the previous step.
- Click Add secret.
After adding the secret, you can manually run the action to generate the new stats.
- In this repository, click on the Actions tab.
- On the left side, select your workflow (e.g., Update GitHub Stats Cards).
- On the right side, click the Run workflow dropdown menu.
- Confirm by clicking the green Run workflow button.
Once the action finishes successfully (shows a green checkmark), your cards (stats.svg, streak.svg, langs.svg) will be automatically updated and will include your private stats!