Skip to content

Commit 36f0e43

Browse files
Updating readme.md
1 parent ca8297c commit 36f0e43

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# PowerShellForGitHub
2+
[![Build status](https://ci.appveyor.com/api/projects/status/t743qp9vfw9f2mq9?svg=true)](https://ci.appveyor.com/project/PowerShell/powershellforgithub)
3+
4+
PowerShell wrapper for GitHub API.
5+
6+
This repository currently contains two modules:
7+
* GitHubAnalytics.psm1 - for querying issues, pull requests, collaborators, contributors, and organizations
8+
* GitHubLabels.psm1 - for operations on GitHub labels
9+
10+
Please scroll down to the "Examples" section for details on what operations are supported.
11+
12+
## Usage
13+
1) Rename ApiTokensTemplate.psm1 to ApiTokens.psm1 and update value of $global:gitHubApiToken with GitHub token for your account
14+
* You can obtain it from https://github.com/settings/tokens).
15+
* If you don't provide GitHub token, you can still use this module, but you will be limited to 60 queries per hour.
16+
17+
2) Import module you want to use and call it's function, e.g.
18+
19+
```powershell
20+
Import-Module .\GitHubAnalytics.psm1
21+
$issues = Get-GitHubIssuesForRepository -repositoryUrl @('https://github.com/PowerShell/DscResources')
22+
```
23+
24+
## Runnig tests
25+
1) Install [Pester](http://www.powershellgallery.com/packages/Pester/3.4.0)
26+
27+
```powershell
28+
Install-Module -Name Pester
29+
```
30+
31+
2) Start test pass
32+
33+
```powershell
34+
Invoke-Pester
35+
```
36+
37+
Make sure ApiTokens.psm1 exists and contains $global:gitHubApiToken with your GitHub key.
38+
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.
39+
40+
## Contributing
41+
42+
Contributions are welcome, please open issue on what functionality you would like to see added/contribute or simply send a pull request.
43+
44+
## Examples
45+
46+
### GitHubAnalytics
47+
48+
#### Querying issues
49+
50+
```powershell
51+
$issues = Get-GitHubIssuesForRepository `
52+
-repositoryUrl @('https://github.com/PowerShell/xPSDesiredStateConfiguration')
53+
```
54+
55+
```powershell
56+
$issues = Get-GitHubWeeklyIssuesForRepository `
57+
-repositoryUrl @('https://github.com/powershell/xpsdesiredstateconfiguration',`
58+
'https://github.com/powershell/xactivedirectory') -datatype closed
59+
```
60+
61+
```powershell
62+
$issues = Get-GitHubTopIssuesRepository `
63+
-repositoryUrl @('https://github.com/powershell/xsharepoint',`
64+
'https://github.com/powershell/xCertificate', 'https://github.com/powershell/xwebadministration') -state open
65+
```
66+
67+
#### Querying pull requests
68+
69+
```powershell
70+
$pullRequests = Get-GitHubPullRequestsForRepository `
71+
-repositoryUrl @('https://github.com/PowerShell/xPSDesiredStateConfiguration')
72+
```
73+
74+
```powershell
75+
$pullRequests = Get-GitHubWeeklyPullRequestsForRepository `
76+
-repositoryUrl @('https://github.com/powershell/xpsdesiredstateconfiguration',`
77+
'https://github.com/powershell/xwebadministration') -datatype merged
78+
```
79+
80+
```powershell
81+
$pullRequests = Get-GitHubTopPullRequestsRepository `
82+
-repositoryUrl @('https://github.com/powershell/xsharepoint', 'https://github.com/powershell/xwebadministration')`
83+
-state closed -mergedOnOrAfter 2015-04-20
84+
```
85+
86+
#### Querying collaborators
87+
88+
```powershell
89+
$collaborators = Get-GitHubRepositoryCollaborators`
90+
-repositoryUrl @('https://github.com/PowerShell/DscResources')
91+
```
92+
93+
#### Querying contributors
94+
95+
```powershell
96+
$contributors = Get-GitHubRepositoryContributors`
97+
-repositoryUrl @('https://github.com/PowerShell/DscResources', 'https://github.com/PowerShell/xWebAdministration')
98+
```
99+
100+
```powershell
101+
$contributors = Get-GitHubRepositoryContributors`
102+
-repositoryUrl @('https://github.com/PowerShell/DscResources','https://github.com/PowerShell/xWebAdministration')
103+
104+
$uniqueContributors = Get-GitHubRepositoryUniqueContributors -contributors $contributors
105+
```
106+
107+
#### Quering teams / organization membership
108+
109+
```powershell
110+
$organizationMembers = Get-GitHubOrganizationMembers -organizationName 'OrganizationName'
111+
$teamMembers = Get-GitHubTeamMembers -organizationName 'OrganizationName' -teamName 'TeamName'
112+
```
113+
114+
### GitHubLabels
115+
116+
#### Getting labels for given repository
117+
```powershell
118+
$labels = Get-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName Powershell
119+
```
120+
121+
#### Adding new label to the repository
122+
```powershell
123+
New-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName PowerShell -labelName TestLabel -labelColor BBBBBB
124+
```
125+
126+
#### Removing specific label from the repository
127+
```powershell
128+
Remove-GitHubLabel -repositoryName desiredstateconfiguration -ownerName powershell -labelName TestLabel
129+
```
130+
131+
#### Updating specific label with new name and color
132+
```powershell
133+
Update-GitHubLabel -repositoryName DesiredStateConfiguration -ownerName Powershell -labelName TestLabel -newLabelName NewTestLabel -labelColor BBBB00
134+
```

0 commit comments

Comments
 (0)