Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Windows PowerShell #117

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/Process-PSModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ jobs:
Process-PSModule:
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v2
secrets: inherit
with:
SkipTests: Desktop
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,39 @@ For a detailed understanding of the framework, [read more about PSModule here](h
### Module Configuration and Environment

- [GH Environment for GitHub CLI](https://cli.github.com/manual/gh_help_environment)

### Usecases

Where should it work?

- Locally as a CLI (native companion on repo level, context aware)
- On a workflow (CI/CD) via a GitHub Action (native companion in a action)
- On other PowerShell compatible automation environments (FunctionApp, Azure Automation, etc)

#### Operations - Where PowerShell shines

You might have multiple environments you support, so should understand profiles/accounts.

Compare with:
- GH Cli
- GitHub Desktop
- GitHub Web portal
- Other GitHub PowerShell modules

#### Native companion on the GitHub Runner

Lets you run GitHub Workflow commands.
Lets you use the GitHub API and either an application, user token or a GitHub Action token

#### Automation

Let it log on as a an application or user, and do things on your behalf.

#### Management

Manage resources in GitHub programmatically. HAve a separate way to declare and manage resources in GitHub.

Compare with:
- Terraform
- Pulumi
- Octokit
8 changes: 4 additions & 4 deletions src/public/Auth/Connect-GitHubAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,21 @@
switch ($Mode) {
'GitHubApp' {
$settings = @{
AccessToken = ConvertTo-SecureString -AsPlainText $tokenResponse.access_token
AccessToken = ConvertTo-SecureString -AsPlainText $tokenResponse.access_token -Force
AccessTokenExpirationDate = (Get-Date).AddSeconds($tokenResponse.expires_in)
AccessTokenType = $tokenResponse.access_token -replace '_.*$', '_*'
ApiBaseUri = 'https://api.github.com'
ApiVersion = '2022-11-28'
AuthType = $AuthType
DeviceFlowType = $Mode
RefreshToken = ConvertTo-SecureString -AsPlainText $tokenResponse.refresh_token
RefreshToken = ConvertTo-SecureString -AsPlainText $tokenResponse.refresh_token -Force
RefreshTokenExpirationDate = (Get-Date).AddSeconds($tokenResponse.refresh_token_expires_in)
Scope = $tokenResponse.scope
}
}
'OAuthApp' {
$settings = @{
AccessToken = ConvertTo-SecureString -AsPlainText $tokenResponse.access_token
AccessToken = ConvertTo-SecureString -AsPlainText $tokenResponse.access_token -Force
AccessTokenType = $tokenResponse.access_token -replace '_.*$', '_*'
ApiBaseUri = 'https://api.github.com'
ApiVersion = '2022-11-28'
Expand Down Expand Up @@ -204,7 +204,7 @@
Reset-GitHubConfig -Scope 'Auth'
$prefix = $gitHubToken.Value -replace '_.*$', '_*'
$settings = @{
AccessToken = ConvertTo-SecureString -AsPlainText $gitHubToken.Value
AccessToken = ConvertTo-SecureString -AsPlainText $gitHubToken.Value -Force
AccessTokenType = $prefix
ApiBaseUri = 'https://api.github.com'
ApiVersion = '2022-11-28'
Expand Down
13 changes: 13 additions & 0 deletions tests/GitHub.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,18 @@ Param(

Write-Verbose "Path to the module: [$Path]" -Verbose

BeforeAll {
Connect-GitHub
}

Describe 'GitHub' {
Context 'Invoke-GitHubAPI' {
It 'Invoke-GitHubAPI function exists' {
Get-Command Invoke-GitHubAPI | Should -Not -BeNullOrEmpty
}

It 'Can be called directly to get ratelimits' {
{ Invoke-GitHubAPI -ApiEndpoint '/rate_limit' -Method GET } | Should -Not -Throw
}
}
}
Loading