Giter Site home page Giter Site logo

powershellforgithub's Introduction

PowerShellForGitHub

Build status

PowerShell wrapper for GitHub API.

This repository currently contains two modules:

  • GitHubAnalytics.psm1 - for querying issues, pull requests, collaborators, contributors, and organizations
  • GitHubLabels.psm1 - for operations on GitHub labels

Please scroll down to the "Examples" section for details on what operations are supported.

Installation

You can get latest release of the PowerShellForGitHub on the PowerShell Gallery

Install-Module -Name PowerShellForGitHub

Usage

  1. Rename ApiTokensTemplate.psm1 to ApiTokens.psm1 and update value of $global:gitHubApiToken with GitHub token for your account
  • You can obtain it from https://github.com/settings/tokens.
  • If you don't provide GitHub token, you can still use this module, but you will be limited to 60 queries per hour.
  • You will need to edit this file from an elevated context.
  1. Import module you want to use and call it's function, e.g.
Import-Module .\GitHubAnalytics.psm1
$issues = Get-GitHubIssuesForRepository -repositoryUrl @('https://github.com/PowerShell/DscResources')

Running tests

  1. Install Pester
Install-Module -Name Pester 
  1. Start test pass

Go to the Tests folder and run:

Invoke-Pester

Make sure ApiTokens.psm1 exists and contains $global:gitHubApiToken with your GitHub key. Please keep in mind some tests may fail on your machine, as they test private items (e.g. secret teams) which your key won't have access to.

Contributing

Contributions are welcome, please open issue on what functionality you would like to see added/contribute or simply send a pull request.

Examples

GitHubAnalytics

Querying issues

$issues = Get-GitHubIssuesForRepository `
-repositoryUrl @('https://github.com/PowerShell/xPSDesiredStateConfiguration')
$issues = Get-GitHubWeeklyIssuesForRepository `
-repositoryUrl @('https://github.com/powershell/xpsdesiredstateconfiguration',`
'https://github.com/powershell/xactivedirectory') -datatype closed
$issues = Get-GitHubTopIssuesRepository `
-repositoryUrl @('https://github.com/powershell/xsharepoint',`
'https://github.com/powershell/xCertificate', 'https://github.com/powershell/xwebadministration') -state open

Querying pull requests

$pullRequests = Get-GitHubPullRequestsForRepository `
-repositoryUrl @('https://github.com/PowerShell/xPSDesiredStateConfiguration')
$pullRequests = Get-GitHubWeeklyPullRequestsForRepository `
-repositoryUrl @('https://github.com/powershell/xpsdesiredstateconfiguration',`
'https://github.com/powershell/xwebadministration') -datatype merged
$pullRequests = Get-GitHubTopPullRequestsRepository `
-repositoryUrl @('https://github.com/powershell/xsharepoint', 'https://github.com/powershell/xwebadministration')`
-state closed -mergedOnOrAfter 2015-04-20

Querying collaborators

$collaborators = Get-GitHubRepositoryCollaborators`
-repositoryUrl @('https://github.com/PowerShell/DscResources')

Querying contributors

$contributors = Get-GitHubRepositoryContributors`
-repositoryUrl @('https://github.com/PowerShell/DscResources', 'https://github.com/PowerShell/xWebAdministration')
$contributors = Get-GitHubRepositoryContributors`
-repositoryUrl @('https://github.com/PowerShell/DscResources','https://github.com/PowerShell/xWebAdministration')

$uniqueContributors = Get-GitHubRepositoryUniqueContributors -contributors $contributors

Quering teams / organization membership

$organizationMembers = Get-GitHubOrganizationMembers -organizationName 'OrganizationName'
$teamMembers = Get-GitHubTeamMembers -organizationName 'OrganizationName' -teamName 'TeamName'

GitHubLabels

Getting labels for given repository

$labels = Get-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName Powershell

Adding new label to the repository

New-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName PowerShell -labelName TestLabel -labelColor BBBBBB

Removing specific label from the repository

Remove-GitHubLabel -repositoryName desiredstateconfiguration -ownerName powershell -labelName TestLabel

Updating specific label with new name and color

Update-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName Powershell -labelName TestLabel -newLabelName NewTestLabel -labelColor BBBB00

powershellforgithub's People

Contributors

jrolstad avatar karolkaczmarek avatar zjalexander avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.