diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index 28b57759..76f99837 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -28,5 +28,3 @@ jobs: Process-PSModule: uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v2 secrets: inherit - with: - SkipTests: Desktop diff --git a/README.md b/README.md index e3a1fc8d..fb62b304 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/public/Auth/Connect-GitHubAccount.ps1 b/src/public/Auth/Connect-GitHubAccount.ps1 index a80bdc7e..6ded1449 100644 --- a/src/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/public/Auth/Connect-GitHubAccount.ps1 @@ -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' @@ -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' diff --git a/src/private/Utilities/Hashtable/Remove-HashtableEntry.ps1 b/src/public/Utilities/Remove-HashtableEntry.ps1 similarity index 100% rename from src/private/Utilities/Hashtable/Remove-HashtableEntry.ps1 rename to src/public/Utilities/Remove-HashtableEntry.ps1 diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 7c5eae56..f09dd883 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -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 + } + } }