Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Latest commit

 

History

History
111 lines (88 loc) · 3.32 KB

readme.md

File metadata and controls

111 lines (88 loc) · 3.32 KB

@stoe/octokit-plugin-org-activity

test codeql publish styled with prettier

Octokit plugin to fetch member activity for a given GitHub organization

Install

$ npm install @stoe/octokit-plugin-org-activity

Usage

Personal Access Token authentication:

import {Octokit} from '@octokit/core'
import org_activity_plugin from '@stoe/octokit-plugin-org-activity'

const MyOctokit = Octokit.plugin(org_activity_plugin)

const octokit = new MyOctokit({
  auth: 'GITHUB_TOKEN'
})

const data = await octokit.listMemberActivityByOrganization({org: 'my-org'})

console.log(data)

GitHub App installation authentication:

import {Octokit} from '@octokit/core'
import {createAppAuth} from '@octokit/auth-app'
import org_activity_plugin from '@stoe/octokit-plugin-org-activity'

const MyOctokit = Octokit.plugin(org_activity_plugin)

const auth = createAppAuth({
  id: APP_ID,
  privateKey: Buffer.from(PRIVATE_KEY_BASE64.trim(), 'base64').toString('ascii'),
  installationId: INSTALLATION_ID
})

const {token} = await auth({type: 'installation'})

const octokit = new MyOctokit({
  auth: token
})

const data = await octokit.listMemberActivityByOrganization({org: 'my-org'})

console.log(data)

Output

[
  {
    login: 'monalisa',
    emails: [],
    role: 'MEMBER',
    contributions: {
      periodStart: '2020-07-31T22:00:00Z',
      periodEnd: '2020-09-29T09:55:47Z',
      isSingleDay: false,
      hasAnyContributions: true,
      hasAnyRestrictedContributions: false,
      hasActivityInThePast: true,
      totalCommitContributions: 1,
      totalRepositoriesWithContributedCommits: 1,
      totalIssueContributions: 1,
      totalRepositoriesWithContributedIssues: 1,
      totalPullRequestContributions: 0,
      totalRepositoriesWithContributedPullRequests: 0,
      totalPullRequestReviewContributions: 0,
      totalRepositoriesWithContributedPullRequestReviews: 0,
      totalRepositoryContributions: 0
    }
  },
  {
    login: 'stoe',
    emails: [ '[email protected]' ],
    role: 'ADMIN',
    contributions: {
      periodStart: '2020-07-31T22:00:00Z',
      periodEnd: '2020-09-29T09:55:47Z',
      isSingleDay: false,
      hasAnyContributions: true,
      hasAnyRestrictedContributions: false,
      hasActivityInThePast: true,
      totalCommitContributions: 4,
      totalRepositoriesWithContributedCommits: 2,
      totalIssueContributions: 2,
      totalRepositoriesWithContributedIssues: 1,
      totalPullRequestContributions: 1,
      totalRepositoriesWithContributedPullRequests: 1,
      totalPullRequestReviewContributions: 0,
      totalRepositoriesWithContributedPullRequestReviews: 0,
      totalRepositoryContributions: 0
    }
  }
]

License