Skip to content

Commit 703c058

Browse files
rickstaaUlyssesZhZo-Bro-23qwerty541
committed
feat: add initial GitHub Action for README stats generation
Introduce a first version of a GitHub Action to generate GitHub README stats. This serves as an alternative to the previous Vercel-based setup, which no longer has a public deployment due to the lack of sponsorship. Co-authored-by: Ulysses Zhan <[email protected]> Co-authored-by: Zohan Subhash <[email protected]> Co-authored-by: Alexandr <[email protected]>
1 parent c72a899 commit 703c058

File tree

14 files changed

+4578
-0
lines changed

14 files changed

+4578
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Action E2E
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
e2e:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Generate stats card
16+
uses: ./
17+
with:
18+
card: stats
19+
options: username=${{ github.repository_owner }}&show_icons=true
20+
path: build/stats.svg
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Generate top languages card
24+
uses: ./
25+
with:
26+
card: top-langs
27+
options: username=${{ github.repository_owner }}&layout=compact&langs_count=6
28+
path: build/top-langs.svg
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Generate pin card
32+
uses: ./
33+
with:
34+
card: pin
35+
options: username=readme-tools&repo=github-readme-stats
36+
path: build/pin-readme-tools-github-readme-stats.svg
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Generate WakaTime card
40+
uses: ./
41+
with:
42+
card: wakatime
43+
options: username=MNZ&layout=compact # Used active username from leaderboard
44+
path: build/wakatime.svg
45+
token: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Verify SVG output
48+
run: |
49+
rg -n "<svg" build/stats.svg
50+
rg -n "<svg" build/top-langs.svg
51+
rg -n "<svg" build/pin-readme-tools-github-readme-stats.svg
52+
rg -n "<svg" build/wakatime.svg
53+
shell: bash

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.DS_Store
3+
.env
4+
.vscode
5+
*.code-workspace

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
pnpm lint-staged
5+
pnpm test

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pnpm-lock.yaml
2+
package-lock.json
3+
yarn.lock

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": false,
3+
"trailingComma": "all"
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 readme-tools
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,124 @@
11
# GitHub Readme Stats Action
2+
3+
Generate [GitHub Readme Stats](https://github.com/readme-tools/github-readme-stats) cards in your GitHub Actions workflow, commit them to your profile repository, and embed them directly from there.
4+
5+
## Quick start
6+
7+
```yaml
8+
name: Update README cards
9+
10+
on:
11+
schedule:
12+
- cron: "0 3 * * *"
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Generate stats card
22+
uses: readme-tools/github-readme-stats-action@v1
23+
with:
24+
card: stats
25+
options: username=${{ github.repository_owner }}&show_icons=true
26+
path: profile/stats.svg
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Generate top languages card
30+
uses: readme-tools/github-readme-stats-action@v1
31+
with:
32+
card: top-langs
33+
options: username=${{ github.repository_owner }}&layout=compact&langs_count=6
34+
path: profile/top-langs.svg
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Generate pin card
38+
uses: readme-tools/github-readme-stats-action@v1
39+
with:
40+
card: pin
41+
options: username=readme-tools&repo=github-readme-stats
42+
path: profile/pin-readme-tools-github-readme-stats.svg
43+
token: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Commit cards
46+
run: |
47+
git config user.name "github-actions"
48+
git config user.email "[email protected]"
49+
git add profile/*.svg
50+
git commit -m "Update README cards" || exit 0
51+
git push
52+
```
53+
54+
Then embed from your profile README:
55+
56+
```md
57+
![Stats](./profile/stats.svg)
58+
![Top Languages](./profile/top-langs.svg)
59+
![Pinned](./profile/pin-readme-tools-github-readme-stats.svg)
60+
```
61+
62+
## Deployment options
63+
64+
This action is a recommended deployment option. You can also deploy on Vercel or other platforms. See the [GitHub Readme Stats README](https://github.com/readme-tools/github-readme-stats#deploy-on-your-own).
65+
66+
## Inputs
67+
68+
- `card` (required): Card type. Supported: `stats`, `top-langs`, `pin`, `wakatime`, `gist`.
69+
- `options`: Card options as a query string (`key=value&...`) or JSON. If `username` is omitted, the action uses the repository owner.
70+
- `path`: Output path for the SVG file. Defaults to `profile/<card>.svg`.
71+
- `token`: GitHub token (PAT or `GITHUB_TOKEN`).
72+
73+
## Examples
74+
75+
Stats example:
76+
77+
```yaml
78+
with:
79+
card: stats
80+
options: username=octocat&show_icons=true&hide_rank=true&bg_color=0D1117
81+
token: ${{ secrets.GITHUB_TOKEN }}
82+
```
83+
84+
Top languages example:
85+
86+
```yaml
87+
with:
88+
card: top-langs
89+
options: username=octocat&layout=compact&langs_count=6
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
```
92+
93+
WakaTime example:
94+
95+
```yaml
96+
with:
97+
card: wakatime
98+
options: username=octocat&layout=compact
99+
token: ${{ secrets.GITHUB_TOKEN }}
100+
```
101+
102+
Gist example:
103+
104+
```yaml
105+
with:
106+
card: gist
107+
options: id=0123456789abcdef
108+
token: ${{ secrets.GITHUB_TOKEN }}
109+
```
110+
111+
JSON options example:
112+
113+
```yaml
114+
with:
115+
card: stats
116+
options: '{"username":"octocat","show_icons":true,"hide_rank":true}'
117+
token: ${{ secrets.GITHUB_TOKEN }}
118+
```
119+
120+
## Notes
121+
122+
- This action uses the same renderers and fetchers as `readme-tools/github-readme-stats`.
123+
- For higher API limits, use a PAT with `public_repo` scope.
124+
# github-readme-stats-action

action.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: GitHub Readme Stats Action
2+
description: Generate GitHub Readme Stats cards in GitHub Actions.
3+
author: readme-tools
4+
inputs:
5+
card:
6+
description: Card type to generate (stats, top-langs, pin, wakatime, gist).
7+
required: true
8+
options:
9+
description: Options for the card (query string or JSON).
10+
required: false
11+
default: ""
12+
path:
13+
description: Output path for SVG file (relative path; include filename with .svg).
14+
required: false
15+
default: ""
16+
token:
17+
description: GitHub token (PAT or GITHUB_TOKEN).
18+
required: false
19+
default: ""
20+
outputs:
21+
path:
22+
description: Path where the SVG file was written.
23+
runs:
24+
using: composite
25+
steps:
26+
- name: Install dependencies
27+
run: npm ci --omit=dev
28+
shell: bash
29+
working-directory: ${{ github.action_path }}
30+
- name: Generate card
31+
run: node ${{ github.action_path }}/index.js
32+
shell: bash
33+
env:
34+
PAT_1: ${{ inputs.token || github.token }}
35+
branding:
36+
icon: bar-chart-2
37+
color: blue

0 commit comments

Comments
 (0)