Skip to content

๐Ÿ“Š An infographics generator with 30+ plugins and 300+ options to display stats about your GitHub account and render them as SVG, Markdown, PDF or JSON!

License

Notifications You must be signed in to change notification settings

hexixiang/metrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š Metrics

Build Metrics (examples)

Generate your metrics that you can embed everywhere, including your GitHub profile readme! It works for both user and organization accounts, and even for repositories!

โš ๏ธ This is the documentation of v3.7-beta (@master branch) which includes unreleased features, see documentation of v3.6 (@latest branch) here.

For user accounts For organization accounts

And you can customize these heavily with plugins, templates and hundreds of options!

๐Ÿงฉ 32 plugins
๐Ÿ“… Isometric commit calendar ๐Ÿˆท๏ธ Most used languages
Full year version
With both total bytes size and percentage version
๐Ÿ™‹ Introduction ๐Ÿ’ก Coding habits
Account version
Repository version
Charts version
๐Ÿ“œ Repository licenses ๐Ÿ… Repository contributors
With licenses ratio
With number of contributions
๐ŸŒŸ Recently starred repositories ๐Ÿ“Œ Starred topics
Mastered and known technologies version
๐ŸŽญ Comment reactions ๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘ People plugin
Followed people version
Special thanks version
Repository template version
๐ŸŽซ Gists ๐ŸŽŸ๏ธ Follow-up of issues and pull requests
๐Ÿ‘จโ€๐Ÿ’ป Lines of code changed ๐Ÿงฎ Repositories traffic
โœจ Stargazers over last weeks ๐Ÿ—‚๏ธ Active projects
๐Ÿ“ฐ Recent activity ๐Ÿ† Achievements
๐ŸŽฉ Notable contributions ๐ŸŒ‡ GitHub Skyline 3D calendar
๐Ÿ—จ๏ธ GitHub Community Support โฑ๏ธ Website performances
Detailed version
With screenshot version
๐ŸŽผ Music plugin ๐Ÿค Latest tweets
๐ŸŽผ Favorite tracks version
Recently listened version
With tweets attachments version
๐ŸŒธ Anilist watch list and reading list ๐Ÿ—จ๏ธ Stackoverflow plugin
Manga version
Favorites characters version
โœ’๏ธ Recent posts ๐Ÿ—ผ Rss feed
With posts descriptions and cover images version
โฐ WakaTime plugin ๐Ÿ’น Stock prices
๐Ÿ“ธ Website screenshot ๐Ÿ’‰ Nightscout
More to come soon!
๐Ÿ–ผ๏ธ 4+ templates
๐Ÿ“— Classic ๐Ÿ“˜ Repository
๐Ÿ“™ Terminal ๐Ÿ“’ Markdown ๐Ÿšง v3.7
๐Ÿ“• Community templates
See documentation ๐ŸŒ

๐Ÿฆ‘ Interested to get your own?

For a fully-featured experience you should use metrics as a GitHub Action, but you can also try it now at metrics.lecoq.io with your GitHub username!

Choose ๐Ÿ“Š Metrics embed if you want to customize your GitHub profile and โœจ Metrics insights to get a quick overview of your GitHub statistics:

๐Ÿ“Š Metrics embed โœจ Metrics insights
Embed metrics images on your profile readme or blog!
Use GitHub actions for even more features!
Share your metrics with friends and on social medias!
No configuration needed!

๐Ÿ“œ How to use?

โš™๏ธ Using GitHub Action on your profile repository (~5 min setup)

Setup a GitHub Action which runs periodically and pushes your generated metrics image to your repository. See all supported options in action.yml.

Assuming your username is my-github-user, you can then embed rendered metrics in your readme like below:

<!-- If you're using "master" as default branch -->
![Metrics](https://github.com/my-github-user/my-github-user/blob/master/github-metrics.svg)
<!-- If you're using "main" as default branch -->
![Metrics](https://github.com/my-github-user/my-github-user/blob/main/github-metrics.svg)
๐Ÿ’ฌ How to setup? (click to expand)

0. Setup your personal repository

Create a repository with the same name as your GitHub login (if it's not already done).

Setup personal repository

Its README.md will be displayed on your user profile:

GitHub Profile Example

1. Create a GitHub personal token

From the Developer settings of your account settings, select Personal access tokens to create a new token.

No additional scopes are needed for basic metrics, but you may have to grant additional scope depending on what features you're planning to use:

  • public_repo scope for some plugins
  • read:org scope for all organizations related metrics
  • repo scope for all private repositories related metrics

Setup a GitHub personal token

A scope-less token can still display private contributions by enabling Include private contributions on my profile in your account settings:

Enable "Include private contributions on my profile`"

If a plugin has not enough scopes to operate (and plugins_errors_fatal isn't enabled), it'll be reported in the rendering like below:

Plugin error example

2. Put your GitHub personal token in your repository secrets

Go to the Settings of your repository to create a new secret and paste your freshly generated GitHub token there.

Setup a repository secret

3. Create a GitHub Action workflow in your repository

Create a new workflow from the Actions tab of your repository and paste the following:

name: Metrics
on:
  # Schedule updates (each hour)
  schedule: [{cron: "0 * * * *"}]
  # Lines below let you run workflow manually and on each commit (optional)
  workflow_dispatch:
  push: {branches: ["master", "main"]}
jobs:
  github-metrics:
    runs-on: ubuntu-latest
    steps:
      # See action.yml for all options
      - uses: lowlighter/metrics@latest
        with:
          # Your GitHub token
          token: ${{ secrets.METRICS_TOKEN }}

See all supported options in action.yml.

Rendered metrics will be committed to your repository on each run.

Action update example

Choosing between @latest, @master or a fork

If you wish to use new features as they're being released, you can switch from @latest to @master. As the latter is used as a development branch, jobs may fail from time to time (although we try to mitigate this).

When using a token with additional permissions, it is advised to fork this repository and use it instead to minimize security risks:

      - uses: my-github-username/metrics@master
      # If you make changes on your fork, be sure not leave @latest as tag!

In this case, please consider watching new releases to stay up-to-date and enjoy latest features!

@latest will be updated on each release soon after Planned for next release is emptied. Metrics doesn't introduce breaking changes from an user point of view (i.e. your workflows will always be valid) so you can follow release cycles without worrying.

Examples workflows

Metrics displayed on this page are rendered from this workflow so you can check it out for some code examples about plugins usage.

You can also take a look at this user workflow if you want.

4. Embed link into your README.md

Update your README.md to embed your metrics:

<!-- If you're using "master" as default branch -->
![Metrics](https://github.com/my-github-user/my-github-user/blob/master/github-metrics.svg)
<!-- If you're using "main" as default branch -->
![Metrics](https://github.com/my-github-user/my-github-user/blob/main/github-metrics.svg)

๐Ÿ’• Using the shared instance (~1 min setup, but with limitations)

For convenience, you can use the shared instance available at metrics.lecoq.io without any additional setup.

![Metrics](https://metrics.lecoq.io/my-github-user)

This is mostly intended for previews, to enjoy all features consider using GitHub Action instead. Availability is not guaranteed.

๐Ÿ’ฌ Fair use (click to expand)

To ensure service availability, shared instance has a few limitations:

  • Images are cached for 1 hour
    • Rendered metrics won't be updated during this time window when queried
    • You can manually update rendering again your metrics on metrics.lecoq.io
  • A rate limiter is enabled to prevent denial of service (it doesn't affect already cached metrics)
  • Some plugins may not be available

Service is provided free of charge, so please be gentle with it ๐Ÿ™‚

๐Ÿ—๏ธ Deploying your own web instance (~15 min setup, depending on your sysadmin knowledge)

Setup a metrics instance on your server if you don't want to use GitHub Actions and metrics.lecoq.io. See all supported options in settings.example.json.

Assuming your username is my-github-user, you can then embed rendered metrics in your readme like below:

![Metrics](https://my-personal-domain.com/my-github-user)
๐Ÿ’ฌ How to setup? (click to expand)

0. Prepare your server

You'll need a server with a recent version NodeJS (see used version in Dockerfile).

1. Create a GitHub personal token

From the Developer settings of your account settings, select Personal access tokens to create a new token.

No additional scopes are needed.

Setup a GitHub personal token

2. Install dependencies

Clone repository, install dependencies and copy configuration example to settings.json:

git clone https://github.com/lowlighter/metrics.git
cd metrics/
npm install --only=prod
cp settings.example.json settings.json

3. Configure your instance and start it

Edit settings.json to configure your instance.

{
  //GitHub API token
    "token":"GITHUB_TOKEN",
  //Other options...
}

See all supported options in settings.example.json.

If you plan to make your web instance public, it is advised to restrict its access thanks to rate limiter and access list.

Once you've finished configuring metrics, start your instance:

npm start

Access your server with provided port in setting.json from your browser to ensure everything is working.

4. Embed link into your README.md

Edit your repository readme and add your metrics image from your server domain:

![Metrics](https://my-personal-domain.com/my-github-user)

6. (optional) Setup your instance as a service

To ensure that your instance will restart if it reboots or crashes, you should set it up as a service. This is described below for Linux-like systems which support systemd.

Create a new service file /etc/systemd/system/github_metrics.service and paste the following after editing paths inside:

[Unit]
Description=Metrics
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/path/to/metrics
ExecStart=/usr/bin/node /path/to/metrics/index.mjs

[Install]
WantedBy=multi-user.target

Reload services, enable it, start it and check if it is up and running:

systemctl daemon-reload
systemctl enable github_metrics
systemctl start github_metrics
systemctl status github_metrics
๐Ÿ”— HTTP parameters (click to expand)

Most of options from action.yml are actually supported by web instance, though syntax is slightly different. All underscores (_) must be replaced by dots (.) and plugin_ prefixes must be dropped.

For example, to configure pagespeed plugin you'd use the following:

https://my-personal-domain.com/my-github-user?pagespeed=1&pagespeed.detailed=1&pagespeed.url=https%3A%2F%2Fexample.com

Note that url parameters must be encoded.

As for base content, which is enabled by default, sections are available through "base.<section>".

For example, to display only repositories section, use:

https://my-personal-domain.com/my-github-user?base=0&base.repositories=1

๐Ÿ“š Documentation

๐Ÿงฐ Template/plugin compatibily matrix

Template\Plugin ๐Ÿ—ƒ๏ธ ๐Ÿ“… ๐Ÿˆท๏ธ ๐Ÿ™‹ ๐Ÿ’ก ๐Ÿ“œ ๐Ÿ… ๐ŸŒŸ ๐Ÿ“Œ ๐ŸŽญ ๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘ ๐ŸŽซ ๐ŸŽŸ๏ธ ๐Ÿ‘จโ€๐Ÿ’ป ๐Ÿงฎ โœจ ๐Ÿ—‚๏ธ ๐Ÿ“ฐ ๐Ÿ† ๐ŸŽฉ ๐ŸŒ‡ ๐Ÿ—จ๏ธ โฑ๏ธ ๐ŸŽผ ๐Ÿค ๐ŸŒธ ๐Ÿ—จ๏ธ โœ’๏ธ ๐Ÿ—ผ โฐ ๐Ÿ’น ๐Ÿ“ธ ๐Ÿ’‰
๐Ÿ“— Classic โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โŒ โŒ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
๐Ÿ“˜ Repository โœ”๏ธ โŒ โœ”๏ธ โœ”๏ธ โŒ โœ”๏ธ โœ”๏ธ โŒ โŒ โŒ โœ”๏ธ โŒ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โŒ โŒ โŒ โŒ โœ”๏ธ โŒ โŒ โŒ โŒ โŒ โœ”๏ธ โŒ โŒ โŒ โŒ
๐Ÿ“™ Terminal โœ”๏ธ โŒ โœ”๏ธ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โœ”๏ธ โŒ โœ”๏ธ โœ”๏ธ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โœ”๏ธ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โŒ
๐Ÿ“’ Markdown ๐Ÿšง v3.7 โœ”๏ธ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โœ”๏ธ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โŒ โœ”๏ธ โŒ โŒ โŒ โŒ โŒ โŒ โœ”๏ธ โŒ โŒ โœ”๏ธ โœ”๏ธ โŒ โŒ โŒ โŒ

๐Ÿ–ผ๏ธ Templates

Templates lets you change general appearance of rendered metrics. See their respective documentation for more informations about how to setup them:

๐Ÿงฉ Plugins

Plugins are features which provide additional content and lets you customize your rendered metrics. See their respective documentation for more informations about how to setup them:

๐Ÿฆ Organizations metrics

While metrics targets mainly user accounts, it's possible to render metrics for organization accounts.

Metrics (organization account)

๐Ÿ’ฌ Metrics for organizations (click to expand)

Setup is the same as for user accounts, though you'll need to add read:org scope, whether you're member of target organization or not.

Add read:org scope to personal token

You'll also need to set user option with your organization name.

If you're encounting errors and your organization is using single sign-on, try to authorize your personal token.

Most of plugins supported by user accounts will work with organization accounts, but note that rendering metrics for organizations consume way more APIs requests.

To support private repositories, add full repo scope to your personal token.

โ„น๏ธ Example workflow

- uses: lowlighter/metrics@latest
  with:
    # ... other options
    token: ${{ secrets.METRICS_TOKEN }}          # A personal token from an user account with read:org scope
    user: organization-name                      # Organization name
๐Ÿ’ฌ Organizations memberships for user accounts (click to expand)

Only public memberships can be displayed by metrics by default. You can manage your membership visibility in the People tab of your organization:

Publish organization membership

For organization memberships, add read:org scope to your personal token.

Add read:org scope to personal token

๐Ÿ’ช Customizing and contributing

Metrics is built to be easily customizable. Fork this repository, switch used action from lowlighter/metrics@latest to your fork and start coding!

See ARCHITECTURE.md for more informations about how code is structured.

To report a bug fill an issue describing it. To suggest new features or requesting help to setup metrics, check out discussions. You can also take a look at issues labeled with help wanted.

If you want to contribute, submit a pull request. Be sure to read CONTRIBUTING.md for more information about this.

๐Ÿ“œ License

MIT License
Copyright (c) 2020-present lowlighter

License details

See full license in LICENSE.md

Sponsors

โ™ฅ๏ธ Become a sponsor

๐Ÿ“– Useful references

โœจ Inspirations

About

๐Ÿ“Š An infographics generator with 30+ plugins and 300+ options to display stats about your GitHub account and render them as SVG, Markdown, PDF or JSON!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 73.3%
  • TypeScript 18.6%
  • HTML 6.2%
  • CSS 1.6%
  • Other 0.3%