Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function Get-GitHubEnterpriseInstallableOrganization {
<#
.SYNOPSIS
Get enterprise-owned organizations that can have GitHub Apps installed

.DESCRIPTION
List of organizations owned by the enterprise on which the authenticated GitHub App installation may install other GitHub Apps.

The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/enterprise_organization_installations
(read) permission.

.EXAMPLE
Get-GitHubEnterpriseInstallableOrganization -Enterprise 'msx'
#>
[CmdletBinding()]
param(
# The enterprise slug or id.
[Parameter(Mandatory)]
[string] $Enterprise
)
$inputObject = @{
APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations"
Method = 'GET'
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
function Install-GitHubAppOnEnterpriseOrganization {
<#
.SYNOPSIS
Install an app on an Enterprise-owned organization

.DESCRIPTION
Installs the provided GitHub App on the specified organization owned by the enterprise.

The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/organization_installations (write) permission.

.EXAMPLE
Install-GitHubAppOnEnterpriseOrganization -Enterprise 'msx' -Organization 'org' -ClientID '123456'
#>
[CmdletBinding()]
param(
# The enterprise slug or ID.
[Parameter(Mandatory)]
[string] $Enterprise,

# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[string] $Organization,

# The client ID of the GitHub App to install.
[Parameter(Mandatory)]
[string] $ClientID,

# The repository selection for the GitHub App. Can be one of:
# - all - all repositories that the authenticated GitHub App installation can access.
# - selected - select specific repositories.
[Parameter()]
[ValidateSet('all', 'selected')]
[string] $RepositorySelection = 'all',

# The names of the repositories to which the installation will be granted access.
[Parameter()]
[string[]] $Repositories
)

$body = @{
client_id = $ClientID
repository_selection = $RepositorySelection
repositories = $Repositories
}
$body | Remove-HashtableEntry -NullOrEmptyValues

$inputObject = @{
APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations"
Method = 'Post'
Body = $body
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}