Skip to content

paritytech/metrics

Repository files navigation

GitHub metrics

Get GitHub metrics for a repository.

Supports obtaining metrics from:

  • Pull Requests
  • Issues

To start

Run from CLI

Copy example.env as .env and replace the variables with your own.

Run:

  • yarn install
  • yarn run cli

It will generate a file named report.md as the output.

Run as GitHub action

Install this action in your repository:

name: Fetch metrics

on:
  workflow_dispatch:
  schedule:
    - cron: "0 12 1 * *"

jobs:
  get_metrics:
    runs-on: ubuntu-latest
    name: Get repository metrics
    steps:
      - uses: paritytech/metrics@main
        name: Fetch metrics
        with:
          GITHUB_TOKEN: ${{ github.token }}
          owner: paritytech
          repo: metrics

Inputs

  • GITHUB_TOKEN: Token to access the repo.
    • If the repo is public, or is the same repo where the action is being executed, you can use ${{ github.token }}
    • If the repo is big (more than 700 PRs), or it is a different private repo you need to use a Personal Access Token with public_repo enabled.
      • This is required because the action's token will hit it's limit before finishing crawling the repository data.
  • owner: Name of the owner of the repository.
    • Optional.
    • Defaults to the owner/organization who is running the action.
  • repo: Name of the repository to crawl.
    • Optional.
    • Default to the repository's name where this action is running.

Outputs

In the action's summary, it will publish the markdown file, so be sure to see the summary (which is different than the logs).

It will also produce a file with the same content as the summary in a file named report.md. Be sure to use this file if you need it for rendering.

It will also output three variables:

  • repo: The name of the repo in owner/repo pattern.
  • pr-report: A JSON string with the metrics obtained from the repository PRs.
  • issue-report: A JSON string with the metrics obtained from the repository issues.

Publish metrics

The action produces a file ./index.html. This file contains all the metrics.

You can deploy this site to GitHub pages if you want to have up to date metrics in a site.

steps:
  - uses: paritytech/metrics@generate-website
    name: Fetch metrics
    id: metric
    with:
      GITHUB_TOKEN: ${{ github.token }}
      owner: paritytech
      repo: metrics
  - name: Setup Pages
    uses: actions/configure-pages@v2
  - name: Upload artifact
    uses: actions/upload-pages-artifact@v1
    with:
      path: ./
  - name: Deploy to GitHub Pages
    id: deployment
    uses: actions/deploy-pages@v1

Releases

No releases published

Packages

No packages published