Skip to contents

Help pages

What it does

Draws cards for your GitHub profile, as SVG files that stay sharp on any screen:

  • Contributions: your contributions since you joined GitHub and in the last 12 months, your commits, your current and longest streaks of days with contributions, and your languages by commits and by repositories.
  • Statistics: your repositories and their stars, how many times they were viewed and cloned, the downloads of your releases and your GitHub Actions runs, with charts of the last 30 days.
  • Activity: your pull requests, issues, reviews and new repositories, your followers, your contributions by type and by day of the week, and the repositories you commit to most.
  • Visitors: the unique visitors and cloners of your repositories in the last 14 days, the sites that sent them and the pages they viewed.
  • GitHub Actions: your runs of the last 30 days, how many succeeded and failed, how long they took and your busiest workflows.
  • Code: the size of your code in each language, your largest repositories, your stars month by month, and your forks and watchers.

rghcard is also a GitHub Action: a workflow in your profile repository refreshes the cards every week and keeps the history of your page views and clones, which GitHub itself keeps for 14 days only. The cards come in the colours of GitHub’s dark and light modes, and your profile shows each reader those of their mode.

A GitHub contributions card of a made-up user: 4.1K contributions since March 2019, 1.2K in the last 12 months, 2.5K commits, a current streak of 23 days and a longest one of 41 days, with the contributions per month as columns, and the languages by commits and by repositories as two rings in GitHub's colours of the languages, each with a legend of their shares

A GitHub statistics card of a made-up user: 8 public repositories, 101 stars, 1.1K page views and 1.4K clones in the last 30 days, 599 release downloads and 86 GitHub Actions runs, with the page views and clones per day as columns and the five most viewed repositories as bars

A GitHub activity card of a made-up user: 654 pull requests, 474 issues, 356 reviews and 14 new repositories since March 2019, and 87 followers, with the contributions by type as a ring with a legend of their shares, the contributions of each day of the week as columns, and the five most committed repositories as bars

A GitHub visitors card of a made-up user: 176 unique visitors, 554 page views and 190 unique cloners in the last 14 days, from 6 referring sites, to 8 of 8 repositories, with the visitors per day as columns, and the top referring sites and the most viewed pages as bars

A GitHub Actions card of a made-up user: 86 runs in the last 30 days, 90% of the finished ones successful, 9 failed, 9.8 hours of run time and 4 workflows in 4 repositories, with the runs per day as columns, and the busiest workflows and the run time by repository as bars

A GitHub code card of a made-up user: 1.1 MB of code in 8 repositories, in 10 languages, mostly R, 101 stars, 38 of them in the last 12 months, 19 forks and 18 watchers, with the code per language as a ring in GitHub's colours of the languages, the stars at the end of each month as columns, and the largest repositories as bars

The cards on your GitHub profile

The workflow runs the rghcard action on GitHub, so this needs no R on your computer.

  1. Your profile repository. GitHub shows on your profile the README of the repository named after your user name, github.com/<you>/<you>. If you have none, create it, public, with a README.

  2. The workflow. In that repository, click Add file > Create new file, name the file .github/workflows/rghcard.yml (typing the slashes makes the folders), paste this, and click Commit changes:

    name: rghcard
    
    on:
      schedule:
        - cron: "17 5 * * 1"   # every Monday at 05:17 UTC
      workflow_dispatch:       # and when you run it from the Actions tab
    
    permissions:
      contents: write          # to commit the cards and their history
    
    jobs:
      cards:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v7
          - uses: sedzinfo/rghcard@v0
            with:
              token: ${{ secrets.RGHCARD_TOKEN }}

    The action installs R and rghcard on GitHub’s machine, collects your statistics, draws the cards and commits them, with their history. @v0 is the latest release of rghcard 0.x. Keep the cron line at least weekly, since GitHub keeps the traffic for 14 days. In R, use_rghcard_action() writes this workflow for you.

  3. A token for the traffic. GitHub shows the page views and clones of a repository only to those who can push to it, so the workflow needs a token of yours. This link opens GitHub’s form for a fine-grained token, filled in: the name rghcard, one permission, Administration: Read-only, which reads the traffic and can change nothing, and Expiration: none, since the cards stop updating when the token expires. GitHub adds Metadata: Read-only, which every token has, by itself. Choose Repository access: All repositories, click Generate token and copy the token: GitHub shows it only once.

  4. The secret. In the profile repository, Settings > Secrets and variables > Actions > New repository secret: name it RGHCARD_TOKEN and paste the token.

  5. The first run. Actions > rghcard > Run workflow. A few minutes later the repository has the cards, rghcard-<card>-dark.svg and rghcard-<card>-light.svg for each card (contributions, stats, activity, visitors, actions and code), and their history, the folder rghcard-data.

  6. The cards in your README. Add this to README.md, or the cards you want of it, in the order you want:

    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="rghcard-contributions-dark.svg"/>
      <img alt="GitHub contributions" src="rghcard-contributions-light.svg" width="100%"/>
    </picture>
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="rghcard-stats-dark.svg"/>
      <img alt="GitHub statistics" src="rghcard-stats-light.svg" width="100%"/>
    </picture>
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="rghcard-activity-dark.svg"/>
      <img alt="GitHub activity" src="rghcard-activity-light.svg" width="100%"/>
    </picture>
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="rghcard-visitors-dark.svg"/>
      <img alt="GitHub visitors" src="rghcard-visitors-light.svg" width="100%"/>
    </picture>
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="rghcard-actions-dark.svg"/>
      <img alt="GitHub Actions" src="rghcard-actions-light.svg" width="100%"/>
    </picture>
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="rghcard-code-dark.svg"/>
      <img alt="GitHub code" src="rghcard-code-light.svg" width="100%"/>
    </picture>

Without the secret, the cards show your public statistics only: stars, forks, languages, release downloads, GitHub Actions runs and contributions, but no page views, clones or visitors. When the token expires or is revoked, the workflow fails with a message saying so, and GitHub tells you of the failed run by email: create a new token, or regenerate the old one, and paste it into the secret.

Options

The inputs of the action, under with:, change the cards:

Input Default What it does
token the workflow’s own token A token of yours that can read the traffic of your repositories, from a secret. The workflow’s own token cannot, so without yours the cards show your public statistics only.
cards contributions stats activity visitors actions code The cards to draw.
themes dark light The themes of the cards: dark, light or both.
format svg The format of the cards: svg, png or both. An SVG card is sharp on any screen and a tenth of the size of a PNG one, which counts in a repository that keeps every version of its cards.
days 30 How many days the statistics card and the GitHub Actions card cover, up to the day before the run: their page views, clones and runs. The visitors card always covers 14 days, those for which GitHub gives the referring sites.
stats-panels The charts of the statistics card, one to three, such as views clones top_starred. Any card can show the charts of the others: Draw the cards in R lists all 23, and The statistics card, The contributions card and More cards explain them. Empty for the default charts.
contributions-panels, activity-panels, visitors-panels, actions-panels, code-panels The charts of the other cards, chosen in the same way. Empty for the default charts.
include-private false Include private repositories, and the commits in them? In a public repository, their names and numbers then become public.
include-forks false Include forks, and the commits in them?
cards-dir . The folder of the cards.
data-dir rghcard-data The folder of the history.
commit true Commit and push the cards and the history? With false, they are only drawn, for a later step.
commit-message Update the GitHub statistics cards The message of the commit.

For example, the dark contributions, statistics and GitHub Actions cards only, of the last 14 days, with other charts:

      - uses: sedzinfo/rghcard@v0
        with:
          token: ${{ secrets.RGHCARD_TOKEN }}
          cards: contributions stats actions
          themes: dark
          days: 14
          stats-panels: views clones top_starred

With one theme, show each card with an <img> alone, such as <img alt="GitHub statistics" src="rghcard-stats-dark.svg" width="100%"/>: there is no card of the other mode for <picture> to choose.

Before version 0.4.0, the cards were PNG files. A profile that still shows rghcard-stats-dark.png and the like shows cards that are no longer updated, and the run warns of them: change .png to .svg in README.md and delete the PNG cards, or keep PNG cards with format: png.

What becomes public

In a public profile repository, the cards and rghcard-data/ are public:

  • the page views, unique visitors, clones and unique cloners of each repository per day, and its ten top referring sites and ten most viewed pages, with their counts;
  • the downloads of each release file, and your GitHub Actions runs, with their times;
  • the bytes of code of each repository in each language, and the time of each star;
  • how many followers you have, and how many users you follow;
  • your contributions per day and by type, which your profile shows anyway, and your commits per repository and year.

Who visits, clones or stars your repositories is never collected: GitHub gives no names for the traffic, and rghcard keeps only the time of each star. Private repositories and forks are left out, and so are the commits in them, unless include-private or include-forks brings them in.

Installation

Only for using rghcard in R: to draw cards on your computer, or to set up the workflow from R. The cards on your GitHub profile need none of this.

1. Install R

Download R 4.1 or newer from CRAN, for Windows, macOS or Linux, and run the installer.

2. Install RStudio or Positron

An editor makes R easier to use. It is optional, and both are free, from Posit:

3. Install rghcard

Run one of these in RStudio, Positron or the R console. Each one also installs the packages rghcard needs.

install.packages(
  "rghcard",
  repos = c("https://sedzinfo.r-universe.dev", "https://cloud.r-project.org")
)

R-universe builds rghcard from this repository after every change, ready to install on Windows, macOS and Linux, and CRAN provides the packages it needs.

From GitHub

install.packages("pak")   # once
pak::pak("sedzinfo/rghcard")

From the release tarball

The Latest build pre-release has the source tarball and the PDF manual, rebuilt from main on every change:

install.packages("pak")   # once
pak::pak("url::https://github.com/sedzinfo/rghcard/releases/download/latest/rghcard_0.4.0.tar.gz")

From a clone of the repository

This repository keeps no files in Git LFS, so a plain clone with Git has everything:

git clone https://github.com/sedzinfo/rghcard.git
install.packages("pak")   # once
pak::local_install("path/to/rghcard")

Usage

library(rghcard)

# try it with made-up statistics, without a token
stats_card(example_stats(), "card.svg")
view_card("card.svg")                                     # in the Viewer pane
view_card("card.svg", "plots")                            # in the Plots pane

# your own statistics: the traffic needs a token of yours, which the gh package finds in the
# GITHUB_PAT environment variable or the git credential store
stats <- collect_stats()                                  # adds to the history in rghcard-data/
contributions_card(stats, "rghcard-contributions.svg")
stats_card(stats, "rghcard-stats.svg")
stats_card(stats, "rghcard-stats-light.svg", theme = "light")

# the other cards
activity_card(stats, "rghcard-activity.svg")
visitors_card(stats, "rghcard-visitors.svg")
actions_card(stats, "rghcard-actions.svg")
code_card(stats, "rghcard-code.svg")

# other charts, another period, a PNG
stats_card(stats, "card.png", days = 14, panels = c("views", "top_cloned", "languages"))

# the public statistics and the contributions of another user
octocat <- collect_stats(user = "octocat", dir = "octocat-data")
contributions_card(octocat, "octocat.svg")
view_card(stats_card(octocat, file = NULL))               # a card without a file

# the workflow, from R: writes .github/workflows/rghcard.yml into your profile repository
use_rghcard_action("path/to/your/profile/repository")

The Get started article shows the cards and how to put them on your profile, and Draw the cards in R goes through doing it in R, step by step: the token, the charts, the history and charts of your own from it. Cards from a user name draws the cards of any user from their user name, in R or in a Shiny app. The contributions card, The statistics card and More cards explain each number and chart, and the help pages every option.


R-universe StarsWatchersRepo SizeOpen IssuesForksLast CommitContributorsLicenseWorkflow StatusR-CMD-check