Skip to content

Commit 974c240

Browse files
🩹 [Patch]: Add Get-GitHubAppInstallation (#131)
## Description - Add Get-GitHubAppInstallation, to list an applications installations (with IDs) ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent c7447f9 commit 974c240

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

src/functions/private/Commands/Initialize-RunnerEnvironment.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Initializes the runner environment for the GitHub module
1313
#>
1414
[CmdletBinding()]
15-
param ()
15+
param()
1616

1717
Write-Verbose 'Detected running on a GitHub Actions runner, preparing environment...'
1818
$env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/'

src/functions/public/Apps/Get-GitHubApp.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#>
2323
[OutputType([pscustomobject])]
2424
[CmdletBinding()]
25-
param ()
25+
param()
2626

2727
$inputObject = @{
2828
APIEndpoint = '/app'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
filter Get-GitHubAppInstallation {
2+
<#
3+
.SYNOPSIS
4+
List installations for the authenticated app
5+
6+
.DESCRIPTION
7+
The permissions the installation has are included under the `permissions` key.
8+
9+
You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app)
10+
to access this endpoint.
11+
12+
13+
.EXAMPLE
14+
An example
15+
16+
.NOTES
17+
[List installations for the authenticated app](https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app)
18+
#>
19+
[CmdletBinding()]
20+
param()
21+
22+
$inputObject = @{
23+
APIEndpoint = '/app/installations'
24+
Method = 'GET'
25+
}
26+
27+
Invoke-GitHubAPI @inputObject | ForEach-Object {
28+
Write-Output $_.Response
29+
}
30+
}

tools/dev/dump.ps1

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,6 @@ query(`$enterpriseSlug: String!, `$first: Int = 100, `$after: String) {
8585

8686
}
8787

88-
function Get-GitHubAppInstallation {
89-
[CmdletBinding()]
90-
param (
91-
[Parameter(Mandatory)]
92-
[string] $Token,
93-
94-
[Parameter()]
95-
$BaseURL = $env:GITHUB_API_URL
96-
)
97-
98-
$result = Invoke-RestMethod -Method Get -Uri "$BaseURL/app/installations" -Headers @{
99-
'Authorization' = "Bearer $token"
100-
'Accept' = 'application/vnd.github+json'
101-
} -FollowRelLink
102-
103-
$result | ForEach-Object {
104-
Write-Output $_
105-
}
106-
}
107-
10888
function Get-GitHubAppInstallationAccessToken {
10989
[CmdletBinding()]
11090
param (

tools/utilities/GitHubAPI.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $response = Invoke-RestMethod -Uri $APIDocURI -Method Get
2121
# @{n = 'PUT'; e = { (($_.value.psobject.Properties.Name) -contains 'PUT') } }, `
2222
# @{n = 'PATCH'; e = { (($_.value.psobject.Properties.Name) -contains 'PATCH') } } | Format-Table
2323

24-
$path = '/app'
24+
$path = '/app/installations'
2525
$method = 'get'
2626
$response.paths.$path.$method
2727
$response.paths.$path.$method.tags | clip # -> Namespace/foldername

0 commit comments

Comments
 (0)