Skip to content
项目

stats-organization/github-readme-stats-action

在 GitHub 查看

关于

GitHub Action to generate GitHub Readme Stats cards.

开发工具

这些数字如何统计

实测星标增长

24小时
0
7天
+1
15天
+3
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

GitHub Readme Stats Action

Generate GitHub Readme Stats cards in your GitHub Actions workflow, commit them to your profile repository, and embed them directly from there.

Quick start

name: Update README cards

on:
  schedule:
    - cron: "0 0 * * *" # Runs once daily at midnight
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    permissions:
      contents: write

    steps:
      - uses: actions/checkout@v6

      - name: Generate stats card
        uses: stats-organization/github-readme-stats-action@v2
        with:
          card: stats
          options: username=${{ github.repository_owner }}&show_icons=true
          path: profile/stats.svg
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Generate top languages card
        uses: stats-organization/github-readme-stats-action@v2
        with:
          card: top-langs
          options: username=${{ github.repository_owner }}&layout=compact&langs_count=6
          path: profile/top-langs.svg
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Generate pin card
        uses: stats-organization/github-readme-stats-action@v2
        with:
          card: pin
          options: username=stats-organization&repo=github-readme-stats
          path: profile/pin-stats-organization-github-readme-stats.svg
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Commit cards
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git add profile/*.svg
          git commit -m "Update README cards" || exit 0
          git push

Then embed from your profile README:

![Stats](./profile/stats.svg)
![Top Languages](./profile/top-langs.svg)
![Pinned](./profile/pin-stats-organization-github-readme-stats.svg)

Deployment options

This action is a recommended deployment option. You can also use our public GitHub-Stats-Extended instance or deploy one yourself.

Inputs

  • card (required): Card type. Supported: stats, top-langs, pin, wakatime, gist.
  • options: Card options as a query string (key=value&...) or JSON. If username is omitted, the action uses the repository owner.
  • path: Output path for the SVG file. Defaults to profile/<card>.svg.
  • token: GitHub token (PAT or GITHUB_TOKEN). For private repo stats, use a PAT with repo and read:user scopes. For any gist, use a PAT with gist scope.
  • core_version: Version of GitHub Stats Extended to use internally. When omitted, the action uses the latest 2.x.x version.
  • fail_on_error: Fail the action when data fetching fails (e.g. a GitHub API rate limit) instead of writing the "Something went wrong" error card.
    Defaults to false for backwards compatibility.
  • Any environment variables are passed through to the underlying GitHub-Stats-Extended library. Most importantly, FETCH_MULTI_PAGE_STARS controls how many pages of repositories are fetched when calculating total stars. It defaults to 10. For example:
    - name: Generate stats card
      uses: stats-organization/github-readme-stats-action@v2
      env:
        FETCH_MULTI_PAGE_STARS: "20"
      with:
        card: stats
        options: username=${{ github.repository_owner }}&show_icons=true
        path: profile/stats.svg
    

Outputs

  • path: Path where the SVG file was written, relative to the workspace.
  • error_type: Error classification from the core library (e.g. MAX_RETRY). Empty when no error occurred or error type is missing.
  • error_message: Error message from the core library. Empty when no error occurred.
  • error_secondary_message: Secondary error message with additional context. Empty when no error occurred or secondary message is missing.

Examples

Stats example:

with:
  card: stats
  options: username=octocat&show_icons=true&hide_rank=true&bg_color=0D1117
  token: ${{ secrets.GITHUB_TOKEN }}

Top languages example:

with:
  card: top-langs
  options: username=octocat&layout=compact&langs_count=6
  token: ${{ secrets.GITHUB_TOKEN }}

WakaTime example:

with:
  card: wakatime
  options: username=octocat&layout=compact
  token: ${{ secrets.GITHUB_TOKEN }}

Gist example:

with:
  card: gist
  options: id=0123456789abcdef
  token: ${{ secrets.PAT }}

JSON options example:

with:
  card: stats
  options: '{"username":"octocat","show_icons":true,"hide_rank":true}'
  token: ${{ secrets.GITHUB_TOKEN }}

Version-pinned example:

with:
  card: stats
  options: username=octocat&show_icons=true
  core_version: 2.1.3
  token: ${{ secrets.GITHUB_TOKEN }}

Notes

探索相关项目

加载中…