|
1 | 1 | # 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 | + |
| 58 | + |
| 59 | + |
| 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 |
0 commit comments