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

Octokit plugin to fetch member activity for a given GitHub organization

License

Notifications You must be signed in to change notification settings

stoe/octokit-plugin-org-activity

Repository files navigation

@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: [ 'stoe@github.com' ],
    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

About

Octokit plugin to fetch member activity for a given GitHub organization

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages