Microsoft PowerShell wrapper for GitHub API
Перейти к файлу
Howard Wolosky 66dba36538
Re-enable parallel platform execution in CI build (#231)
In a previous commit (b4439f4a6b), the three platforms in the CI pipeline (Windows, Linux, and Mac) were modified to execute serially since they were all operating against the same shared test account, which caused the Pester tests to operate unstabily.

I've now created multiple test accounts so that that each platform can operate in isolation of each other.  I've updated the UT template to accept parameter input, and modified the CI (and release) pipeline to reference a different AccessToken/OwnerName/OrganizationName based on which platform is being targeted.

Additionally:

 * Had to fix some tests to keep everything passing as well;
    * Two Contents tests started failing again because GitHub once again changed the HTML output for the standard generated README.md file.  This time around, I've attempted to make the tests more robust to future changes.
   * Two RepositoryForks tests were unreliable in the way that they were written, so they were updated as well to be more robust when being executed in a parallel UT environment (since we can't control when a fork for this repository is being created/removed).
 * Updates the pipelines to always use the most recent OS images.
 * Fixes some invalid links on some of the Azure DevOps badges in the README
2020-06-10 07:09:10 -07:00
.github Add 'References' section to pull request template 2020-06-01 17:08:31 -07:00
.vscode Adding Get Repository.Contents functionality (#146) 2020-04-03 11:13:53 -07:00
Tests Re-enable parallel platform execution in CI build (#231) 2020-06-10 07:09:10 -07:00
build Re-enable parallel platform execution in CI build (#231) 2020-06-10 07:09:10 -07:00
.editorconfig Adding Get Repository.Contents functionality (#146) 2020-04-03 11:13:53 -07:00
.gitattributes Fixing the CI build (#183) 2020-05-28 16:29:18 -07:00
.gitignore Removing binary dependencies for telemetry (#186) 2020-06-01 13:56:03 -07:00
CHANGELOG.md Update module to 0.14.0 (#203) 2020-05-30 22:14:51 -07:00
CODE_OF_CONDUCT.md Module restructure to v0.2.0 2018-11-13 01:49:21 -08:00
CONTRIBUTING.md Add tests to GitHubRepositories.tests.ps1 (#176) 2020-06-03 16:05:08 -07:00
GOVERNANCE.md Module restructure to v0.2.0 2018-11-13 01:49:21 -08:00
GitHubAnalytics.ps1 Get PSScriptAnalyzer clean again (#180) 2020-05-26 08:01:17 -07:00
GitHubAssignees.ps1 BREAKING CHANGE: Add confirmation prompts and examples for Remove- functions (#174) 2020-06-01 11:03:30 -07:00
GitHubBranches.ps1 Fix named branch querying in Get-GitHubRepositoryBranch (#188) 2020-05-28 10:55:49 -07:00
GitHubComments.ps1 BREAKING CHANGE: Add confirmation prompts and examples for Remove- functions (#174) 2020-06-01 11:03:30 -07:00
GitHubConfiguration.ps1 Removing binary dependencies for telemetry (#186) 2020-06-01 13:56:03 -07:00
GitHubContents.ps1 spelling fixes (#165) 2020-05-07 15:04:51 -07:00
GitHubCore.ps1 Removing binary dependencies for telemetry (#186) 2020-06-01 13:56:03 -07:00
GitHubEvents.ps1 spelling fixes (#165) 2020-05-07 15:04:51 -07:00
GitHubIssues.ps1 Removing binary dependencies for telemetry (#186) 2020-06-01 13:56:03 -07:00
GitHubLabels.ps1 BREAKING CHANGE: Add confirmation prompts and examples for Remove- functions (#174) 2020-06-01 11:03:30 -07:00
GitHubMilestones.ps1 BREAKING CHANGE: Add confirmation prompts and examples for Remove- functions (#174) 2020-06-01 11:03:30 -07:00
GitHubMiscellaneous.ps1 Get PSScriptAnalyzer clean again (#180) 2020-05-26 08:01:17 -07:00
GitHubOrganizations.ps1 Get PSScriptAnalyzer clean again (#180) 2020-05-26 08:01:17 -07:00
GitHubProjectCards.ps1 BREAKING CHANGE: Add confirmation prompts and examples for Remove- functions (#174) 2020-06-01 11:03:30 -07:00
GitHubProjectColumns.ps1 BREAKING CHANGE: Add confirmation prompts and examples for Remove- functions (#174) 2020-06-01 11:03:30 -07:00
GitHubProjects.ps1 BREAKING CHANGE: Add confirmation prompts and examples for Remove- functions (#174) 2020-06-01 11:03:30 -07:00
GitHubPullRequests.ps1 spelling fixes (#165) 2020-05-07 15:04:51 -07:00
GitHubReleases.ps1 spelling fixes (#165) 2020-05-07 15:04:51 -07:00
GitHubRepositories.ps1 GitHubRepositories: Add Additional Parameters (#192) 2020-06-09 15:17:09 -07:00
GitHubRepositoryForks.ps1 Get PSScriptAnalyzer clean again (#180) 2020-05-26 08:01:17 -07:00
GitHubRepositoryTraffic.ps1 Get PSScriptAnalyzer clean again (#180) 2020-05-26 08:01:17 -07:00
GitHubTeams.ps1 Get PSScriptAnalyzer clean again (#180) 2020-05-26 08:01:17 -07:00
GitHubUsers.ps1 Get PSScriptAnalyzer clean again (#180) 2020-05-26 08:01:17 -07:00
Helpers.ps1 Get PSScriptAnalyzer clean again (#180) 2020-05-26 08:01:17 -07:00
LICENSE Updating license 2016-07-26 13:36:21 -07:00
PowerShellForGitHub.psd1 Removing binary dependencies for telemetry (#186) 2020-06-01 13:56:03 -07:00
PowerShellForGitHub.psm1 Prevent `ConvertTo-SmarterObject` from flattening arrays (#56) 2018-11-30 11:26:13 -08:00
README.md Re-enable parallel platform execution in CI build (#231) 2020-06-10 07:09:10 -07:00
SECURITY.md Add security reporting policy documentation (#201) 2020-05-30 15:43:09 -07:00
Telemetry.ps1 Removing binary dependencies for telemetry (#186) 2020-06-01 13:56:03 -07:00
USAGE.md Project Usage (#164) 2020-05-12 10:48:49 -07:00
UpdateCheck.ps1 UpdateCheck must handle when module is newer than published version (#204) 2020-05-31 00:24:35 -07:00

README.md

PowerShellForGitHub PowerShell Module

[GitHub version] powershellgallery downloads GitHub code size in bytes downloads CII Best Practices tweet
Build status Azure DevOps tests Azure DevOps coverage
Help Wanted Issues GitHub last commit

Table of Contents


Overview

This is a PowerShell module that provides command-line interaction and automation for the GitHub v3 API.


Current API Support

At present, this module can:

Development is ongoing, with the goal to add broad support for the entire API set.

For a comprehensive look at what work is remaining to be API Complete, refer to Issue #70.

Review examples to see how the module can be used to accomplish some of these tasks.


Installation

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

Install-Module -Name PowerShellForGitHub

Configuration

To avoid severe API rate limiting by GitHub, you should configure the module with your own personal access token.

  1. Create a new API token by going to https://github.com/settings/tokens/new (provide a description and check any appropriate scopes)
  2. Call Set-GitHubAuthentication, enter anything as the username (the username is ignored but required by the dialog that pops up), and paste in the API token as the password. That will be securely cached to disk and will persist across all future PowerShell sessions. If you ever wish to clear it in the future, just call Clear-GitHubAuthentication).

For automated scenarios (like GithHub Actions) where you are dynamically getting the access token needed for authentication, refer to Example 2 in Get-Help Set-GitHubAuthentication -Examples for how to configure in a promptless fashion.

Alternatively, you could configure PowerShell itself to always pass in a plain-text access token to any command (by setting $PSDefaultParameterValues["*-GitHub*:AccessToken"] = "<access token>"), although keep in mind that this is insecure (any other process could access this plain-text value).

A number of additional configuration options exist with this module, and they can be configured for just the current session or to persist across all future sessions with Set-GitHubConfiguration. For a full explanation of all possible configurations, run the following:

Get-Help Set-GitHubConfiguration -ShowWindow

For example, if you tend to work on the same repository, you can save yourself a lot of typing by configuring the default OwnerName and/or RepositoryName that you work with. You can always override these values by explicitly providing a value for the parameter in an individual command, but for the common scenario, you'd have less typing to do.

Set-GitHubConfiguration -DefaultOwnerName PowerShell
Set-GitHubConfiguration -DefaultRepositoryName PowerShellForGitHub

Be warned that there are some commands where you may want to only ever supply the OwnerName (like if you're calling Get-GitHubRepository and want to see all the repositories owned by a particular user, as opposed to getting a single, specific repository). In cases like that, you'll need to explicitly pass in $null as the relevant parameter value as a temporary override for your default if you've set a default for one (or both) of these values.

There are more great configuration options available. Just review the help for that command for the most up-to-date list!

GitHub Enterprise

To set the configuration to use a GitHub Enterprise server instead of GitHub.com, simply supply the ApiHostName parameter with the hostname of your GitHub Enterprise server.

Set-GitHubConfiguration -ApiHostName "github.contoso.com"

Usage

Example command:

$issues = Get-GitHubIssue -Uri 'https://github.com/PowerShell/PowerShellForGitHub'

For more example commands, please refer to USAGE.


Developing and Contributing

Please see the Contribution Guide for information on how to develop and contribute.

If you have any problems, please consult GitHub Issues to see if has already been discussed.

If you do not see your problem captured, please file feedback.


PowerShellForGitHub is licensed under the MIT license.


Governance

Governance policy for this project is described here.


Code of Conduct

For more info, see CODE_OF_CONDUCT


Reporting Security Issues

Please refer to SECURITY.md.


Privacy Policy

For more information, refer to Microsoft's Privacy Policy.