Skip to content

Commit 5df91f9

Browse files
rickstaaUlyssesZhZo-Bro-23qwerty541
authored
docs: add github action as recommended usage method (anuraghazra#4716)
* docs: add github action as recommended usage method Add new github action as recommended usage method now that we are no longer sponsored by vercel and the hosted endpoint is not available anymore. Co-authored-by: Ulysses Zhan <UlyssesZhan@gmail.com> Co-authored-by: Zohan Subhash <zohan.subhash@gmail.com> Co-authored-by: Alexandr <qwerty541zxc@gmail.com> * docs: improve action section --------- Co-authored-by: Ulysses Zhan <UlyssesZhan@gmail.com> Co-authored-by: Zohan Subhash <zohan.subhash@gmail.com> Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
1 parent 8108ba1 commit 5df91f9

File tree

1 file changed

+65
-14
lines changed

1 file changed

+65
-14
lines changed

readme.md

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@
8585
- [Stats and top languages cards](#stats-and-top-languages-cards)
8686
- [Pinning repositories](#pinning-repositories)
8787
- [Deploy on your own](#deploy-on-your-own)
88-
- [First step: get your Personal Access Token (PAT)](#first-step-get-your-personal-access-token-pat)
89-
- [Classic token](#classic-token)
90-
- [Fine-grained token](#fine-grained-token)
91-
- [On Vercel](#on-vercel)
88+
- [GitHub Actions (Recommended)](#github-actions-recommended)
89+
- [Self-hosted (Vercel/Other) (Recommended)](#self-hosted-vercelother-recommended)
90+
- [First step: get your Personal Access Token (PAT)](#first-step-get-your-personal-access-token-pat)
91+
- [On Vercel](#on-vercel)
9292
- [:film\_projector: Check Out Step By Step Video Tutorial By @codeSTACKr](#film_projector-check-out-step-by-step-video-tutorial-by-codestackr)
93-
- [On other platforms](#on-other-platforms)
94-
- [Available environment variables](#available-environment-variables)
93+
- [On other platforms](#on-other-platforms)
94+
- [Available environment variables](#available-environment-variables)
9595
- [Keep your fork up to date](#keep-your-fork-up-to-date)
9696
- [:sparkling\_heart: Support the project](#sparkling_heart-support-the-project)
9797
</details>
9898

9999
# Important Notices <!-- omit in toc -->
100100

101101
> [!IMPORTANT]
102-
> Since the GitHub API only [allows 5k requests per hour per user account](https://docs.github.com/en/graphql/overview/resource-limitations), the public Vercel instance hosted on `https://github-readme-stats.vercel.app/api` could possibly hit the rate limiter (see [#1471](https://github.com/anuraghazra/github-readme-stats/issues/1471)). We use caching to prevent this from happening (see https://github.com/anuraghazra/github-readme-stats#common-options). You can turn off these rate limit protections by [deploying your own Vercel instance](#deploy-on-your-own).
102+
> The public Vercel instance at `https://github-readme-stats.vercel.app/api` is best-effort and can be unreliable due to rate limits and traffic spikes (see [#1471](https://github.com/anuraghazra/github-readme-stats/issues/1471)). We use caching to improve stability (see [common options](#common-options)), but for reliable cards we recommend [self-hosting](#deploy-on-your-own) (Vercel or other) or using the [GitHub Actions workflow](#github-actions-recommended) to generate cards in your [profile repository](https://docs.github.com/en/account-and-profile/how-tos/profile-customization/managing-your-profile-readme).
103103
104104
<img alt="Uptime Badge" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgithub-readme-stats-git-monitoring-github-readme-stats-team.vercel.app%2Fapi%2Fstatus%2Fup%3Ftype%3Dshields">
105105

@@ -796,15 +796,66 @@ By default, GitHub does not lay out the cards side by side. To do that, you can
796796

797797
</details>
798798

799-
# Deploy on your own
799+
# Deploy on your own (recommended)
800800

801-
## First step: get your Personal Access Token (PAT)
801+
Because the public endpoint is [not reliable](#Important-Notices), we recommend self-deployment via GitHub Actions or your own hosted instance. GitHub Actions is the simplest setup with static SVGs stored in your repo but less frequent updates, while self-hosting takes more work and can serve fresher stats (with caching).
802+
803+
## GitHub Actions
804+
805+
GitHub Actions generates static SVGs and avoids per-request API calls. By default it uses `GITHUB_TOKEN` (public stats only), for private stats, set a [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) as a secret and pass it to the action instead.
806+
807+
Create `/.github/workflows/grs.yml` in your profile repo (`USERNAME/USERNAME`):
808+
809+
```yaml
810+
name: Update README cards
811+
812+
on:
813+
schedule:
814+
- cron: "0 3 * * *"
815+
workflow_dispatch:
816+
817+
jobs:
818+
build:
819+
runs-on: ubuntu-latest
820+
steps:
821+
- uses: actions/checkout@v4
822+
823+
- name: Generate stats card
824+
uses: readme-tools/github-readme-stats-action@v1
825+
with:
826+
card: stats
827+
options: username=${{ github.repository_owner }}&show_icons=true
828+
path: profile/stats.svg
829+
token: ${{ secrets.GITHUB_TOKEN }}
830+
831+
- name: Commit cards
832+
run: |
833+
git config user.name "github-actions"
834+
git config user.email "github-actions@users.noreply.github.com"
835+
git add profile/*.svg
836+
git commit -m "Update README cards" || exit 0
837+
git push
838+
```
839+
840+
Then embed from your profile README:
841+
842+
```md
843+
![Stats](./profile/stats.svg)
844+
```
845+
846+
See more options and examples in the [GitHub Readme Stats Action README](https://github.com/readme-tools/github-readme-stats-action#readme).
847+
848+
## Self-hosted (Vercel/Other)
849+
850+
Running your own instance avoids public rate limits and gives you full control over caching, tokens, and private stats.
851+
852+
### First step: get your Personal Access Token (PAT)
802853

803854
For deploying your own instance of GitHub Readme Stats, you will need to create a GitHub Personal Access Token (PAT). Below are the steps to create one and the scopes you need to select for both classic and fine-grained tokens.
804855

805856
Selecting the right scopes for your token is important in case you want to display private contributions on your cards.
806857

807-
### Classic token
858+
#### Classic token
808859

809860
* Go to [Account -> Settings -> Developer Settings -> Personal access tokens -> Tokens (classic)](https://github.com/settings/tokens).
810861
* Click on `Generate new token -> Generate new token (classic)`.
@@ -813,7 +864,7 @@ Selecting the right scopes for your token is important in case you want to displ
813864
* read:user
814865
* Click on `Generate token` and copy it.
815866

816-
### Fine-grained token
867+
#### Fine-grained token
817868

818869
> [!WARNING]\
819870
> This limits the scope to issues in your repositories and includes only public commits.
@@ -830,7 +881,7 @@ Selecting the right scopes for your token is important in case you want to displ
830881
* Pull requests: read-only
831882
* Click on `Generate token` and copy it.
832883

833-
## On Vercel
884+
### On Vercel
834885

835886
### :film\_projector: [Check Out Step By Step Video Tutorial By @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
836887

@@ -866,7 +917,7 @@ Since the GitHub API only allows 5k requests per hour, my `https://github-readme
866917

867918
</details>
868919

869-
## On other platforms
920+
### On other platforms
870921

871922
> [!WARNING]
872923
> This way of using GRS is not officially supported and was added to cater to some particular use cases where Vercel could not be used (e.g. [#2341](https://github.com/anuraghazra/github-readme-stats/discussions/2341)). The support for this method, therefore, is limited.
@@ -883,7 +934,7 @@ Since the GitHub API only allows 5k requests per hour, my `https://github-readme
883934
5. You're done 🎉
884935
</details>
885936

886-
## Available environment variables
937+
### Available environment variables
887938

888939
GitHub Readme Stats provides several environment variables that can be used to customize the behavior of your self-hosted instance. These include:
889940

0 commit comments

Comments
 (0)