# Github Champion (`mihails/github-champion`) Actor

Find your organization's top contributors. In every time period, performance is measured by the number of assigned issues closed, number of PR reviews, and number of PRs opened.

- **URL**: https://apify.com/mihails/github-champion.md
- **Developed by:** [Mihails Murasovs](https://apify.com/mihails) (community)
- **Categories:** Other, Open source
- **Stats:** 10 total users, 0 monthly users, 0.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## GitHub Champion

Metrics aren't fun. What if they could be?

Celebrate your organization's unsung heroes, identify the quiet contributors who make a difference, and see who will dethrone the reigning champion.

Find the top 3 contributors from your organization and each of your repositories for your chosen time period. The winners are decided by number of assigned issues closed, number of PR reviews, and number of PRs opened. In addition, the actor also gathers metrics like additions, deletions, and commits for everyone who contributed to the repo, if you're into more details.

You can [integrate](./src/helpers.js) this actor with your curent sprints. Use Apify [schedules](https://docs.apify.com/schedules) to synchronize these reports with your company's sprints. Combine it with [webhooks](https://docs.apify.com/webhooks) and have the results sent to you right after they are gathered.

Who is your organization's GitHub Champion?

### How to use

To use this actor with private repositories, you will need a GitHub API token with the **repo** permission granted  - create it at <https://github.com/settings/tokens/new> and paste it into the **githubApiToken** input.

If you keep getting a `Not Found` error, it's probably to do with your authentication token. Make sure the entire `repo` permission is selected.

![API token settings](src/images/token_permissions.png)

By default, releases are not counted.

You will also need to make sure issues are **assigned** correctly (it's good practice anyway :)). One of the main metrics for the actor is the **number of issues closed** by each contributor.

### How it works

The actor makes a few requests to GitHub's API to get your repositories' stats. It then crunches the data for each repo and each contributor, discards the empty entries, and returns the goods.

**Closed issues** count for 1 point, **pull request reviews** count for 0.75 pints,  while **created pull requests** count for half a point. The score is added, and the person with the highest score wins!

### What it doesn't do

This actor **doesn't include the number of additions, deletions, and commits** in its calculation. Some of us commit everything, others like to bundle it all into one. Some of us do package updates, which amount to thousands of added and deleted lines.

### Output

The top 3 contributors from each repository are added to the `top-contributors.json` file in the `top-threes` [key-value store](https://docs.apify.com/storage/key-value-store).

Sample top 3 array:

```json
[
  {
    "Organization All-stars": [
      {
        "name": "gandalf",
        "total": 29.5,
        "pullReviews": 25,
        "issuesClosed": 3,
        "pullsCreated": 3
      },
      {
        "name": "samwise",
        "total": 24.5,
        "pullReviews": 16,
        "issuesClosed": 5,
        "pullsCreated": 7
      },
      {
        "name": "frodo",
        "total": 20,
        "pullReviews": 16,
        "issuesClosed": 1,
        "pullsCreated": 6
      }
    ]
  },
  {
    "apify-web": [
      {
        "name": "gandalf",
        "total": 27,
        "pullReviews": 11,
        "issuesClosed": 12,
        "pullsCreated": 8
      },
      {
        "name": "frodo",
        "total": 18.5,
        "pullReviews": 12,
        "issuesClosed": 6,
        "pullsCreated": 1
      },
      {
        "name": "former-champ",
        "total": 10,
        "pullReviews": 10,
        "issuesClosed": 0,
        "pullsCreated": 0
      }
    ]
  },
  {
    "apify-core": [
      {
        "name": "winner",
        "total": 14.5,
        "pullReviews": 10,
        "issuesClosed": 0,
        "pullsCreated": 9
      },
      {
        "name": "hello-user",
        "total": 13,
        "pullReviews": 4,
        "issuesClosed": 7,
        "pullsCreated": 4
      },
      {
        "name": "future-champ",
        "total": 6.5,
        "pullReviews": 6,
        "issuesClosed": 0,
        "pullsCreated": 1
      }
    ]
  }
]
```

More detailed breakdowns of each repository are available in the `detailed-repo-metrics` key-value-store.

Sample detailed breakdown:

```json
[
  {
    "id": "former-champ",
    "additions": 0,
    "deletions": 0,
    "commits": 0,
    "pullsCreated": 0,
    "pullReviews": 10,
    "issuesClosed": 0
  },
  {
    "id": "team-leader",
    "additions": 4,
    "deletions": 2,
    "commits": 1,
    "pullsCreated": 1,
    "pullReviews": 1,
    "issuesClosed": 0
  },
  {
    "id": "cto",
    "additions": 0,
    "deletions": 0,
    "commits": 0,
    "pullsCreated": 0,
    "pullReviews": 6,
    "issuesClosed": 0
  },
  {
    "id": "frodo",
    "additions": 123,
    "deletions": 54,
    "commits": 2,
    "pullsCreated": 1,
    "pullReviews": 12,
    "issuesClosed": 6
  },
  {
    "id": "casual-contributor",
    "additions": 0,
    "deletions": 0,
    "commits": 0,
    "pullsCreated": 0,
    "pullReviews": 5,
    "issuesClosed": 1
  },
  {
    "id": "gandalf",
    "additions": 15652,
    "deletions": 16589,
    "commits": 13,
    "pullsCreated": 8,
    "pullReviews": 11,
    "issuesClosed": 12
  },
  {
    "id": "samwise",
    "additions": 17,
    "deletions": 4,
    "commits": 1,
    "pullsCreated": 1,
    "pullReviews": 0,
    "issuesClosed": 0
  }
]
```

# Actor input Schema

## `githubApiToken` (type: `string`):

To use this actor with private repositories, you will need a GitHub API token with the **repo** permission granted  - create it at https://github.com/settings/tokens/new

## `repositoryOwner` (type: `string`):

The owner's or organization's name. E.g. "apify"

## `accountType` (type: `string`):

For private repositories, you will need an API token with the 'repo' permission.

## `repositories` (type: `array`):

A JSON array of repository names. E.g. \["apify-docs", "apify-web"]. If left blank, the actor will include all of the owner's repositories.

## `numberOfWeeks` (type: `integer`):

The number of weeks, from the day of the actor's run, to monitor. E.g. If you would like to monitor the activity from the past 4 weeks, enter 4. Defaults to 2.

## Actor input object example

```json
{
  "repositoryOwner": "apify",
  "accountType": "public",
  "repositories": [],
  "numberOfWeeks": 2
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "repositoryOwner": "apify",
    "repositories": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("mihails/github-champion").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "repositoryOwner": "apify",
    "repositories": [],
}

# Run the Actor and wait for it to finish
run = client.actor("mihails/github-champion").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "repositoryOwner": "apify",
  "repositories": []
}' |
apify call mihails/github-champion --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mihails/github-champion"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/UquQj97M1kV8lyISJ/builds/Vd5PsUjqSbRKZZ1B3/openapi.json
