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

🩹 [Patch]: Re-arrange examples #201

Merged
merged 19 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b452f31
examples
Dec 13, 2024
885d09a
Move examples
MariusStorhaug Dec 13, 2024
531bca2
Add a GitHub AuthType Enum
MariusStorhaug Dec 13, 2024
16835a7
Add GitHubAuthType data type on GitHubContext.AuthType
MariusStorhaug Dec 13, 2024
ba99044
Use GitHubAuthType on Assert-GitHubContext
MariusStorhaug Dec 13, 2024
d534a61
Add Assert-GitHubContext on Get-GitHubAppWebhookConfiguration
MariusStorhaug Dec 13, 2024
7d93e87
Rename AuthType
MariusStorhaug Dec 13, 2024
a72d31c
Introduce UserGitHubContextAuthAppType enum and update DeviceFlowType…
MariusStorhaug Dec 13, 2024
00c9b10
Change ApiBaseUri type from string to uri in GitHubContext class
MariusStorhaug Dec 13, 2024
4728a22
Refactor GitHubContext to use enums for Type, AuthType, and TokenType…
MariusStorhaug Dec 13, 2024
c45a1c8
Add .ToString() for enum values
MariusStorhaug Dec 13, 2024
18f050b
Fix
MariusStorhaug Dec 13, 2024
2027edb
Refactor GitHub App scripts to use Assert-GitHubContext for App authe…
MariusStorhaug Dec 13, 2024
b24bfd6
revert
MariusStorhaug Dec 13, 2024
f1b4506
Refactor Get-GitHubContext and Set-GitHubContext to use string litera…
MariusStorhaug Dec 13, 2024
e2872c7
Refactor GitHub App scripts to streamline context resolution and auth…
MariusStorhaug Dec 13, 2024
929261b
Refactor Set-GitHubContext to improve context type handling and verbo…
MariusStorhaug Dec 13, 2024
197450a
Refactor GitHub context handling to improve type consistency and logging
MariusStorhaug Dec 13, 2024
7945365
Merge branch 'main' of https://github.com/PSModule/GitHub into examples
MariusStorhaug Dec 13, 2024
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
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions examples/Apps/EnterpriseApps.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$appIDs = @(
'qweqweqwe',
'qweqweqweqwe'
)

$organization = '*'
filter Install-GithubApp {
param(
[Parameter()]
[string] $Enterprise = 'msx',

[Parameter()]
[string] $Organization = '*',

[Parameter(
Mandatory,
ValueFromPipeline
)]
[string] $AppID
)

begin {

}

process {
$installableOrgs = Get-GitHubEnterpriseInstallableOrganization -Enterprise $Enterprise -Debug -Verbose
$orgs = $installableOrgs | Where-Object { $_.login -like $organization }
foreach ($org in $orgs) {
foreach ($appIDitem in $AppID) {
Install-GitHubAppOnEnterpriseOrganization -Enterprise $Enterprise -Organization $org.login -ClientID $appIDitem -RepositorySelection all | ForEach-Object {
[PSCustomObject]@{
Organization = $org.login
AppID = $appIDitem
}
}
}
}
}

end {

}
}

$appIDs | Install-GithubApp -Organization $organization -Debug -Verbose

$installation = Get-GitHubAppInstallation
33 changes: 33 additions & 0 deletions examples/Apps/Get-WebhookDelivery.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Connect-GitHub -ClientID $ClientID -PrivateKey $PrivateKey -HostName 'msx.ghe.com'

$deliveries = Get-GitHubAppWebhookDelivery | ForEach-Object {
[pscustomobject]@{
Success = ($_.status_code -lt 300) -and ($_.status_code -ge 200)
StatusCode = $_.status_code
Status = $_.status
ID = $_.id
GUID = $_.guid
Date = $_.delivered_at
Duration = $_.duration
Redelivery = $_.redelivery
Event = $_.event
Action = $_.action
InstallationID = $_.installation.id
RepositoryID = $_.repository.id
URL = $_.url
ThrottledAt = $_.throttled_at
}
}

$deliveries | Where-Object { $_.Event -eq 'team' } | Format-Table -AutoSize




$Return.Response | Format-Table -AutoSize

Set-GitHubDefaultContext -Context 'msx.ghe.com/Marius-Storhaug'

1..10 | ForEach-Object {
New-GitHubTeam -Organization 'my-org' -Name "Test$_"
}
1 change: 1 addition & 0 deletions examples/Teams/Get-AllTeams.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

39 changes: 39 additions & 0 deletions examples/Teams/Teams.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
$filter = 'my-org'

$allOrgs = Get-GitHubOrganization $filter -Verbose
$orgs = $allOrgs | Where-Object { $_.login -like $filter }

$orgs | Select-Object login, id, disk_usage
foreach ($org in $orgs) {
1..100 | ForEach-Object {
New-GitHubTeam -Organization $org.login -Name "Team$_" -Description "Team $_" -Verbose
}
}


$Teams = Get-GitHubTeamListByOrg -Organization $filter | ForEach-Object {
[pscustomobject]@{
Organization = $filter
Name = $_.name
Id = $_.id
}
}


$orgs = Get-GitHubOrganization
$teams = $orgs | ForEach-Object {
$org = $_.login
Get-GitHubTeamListByOrg -Organization $org | ForEach-Object {
[pscustomobject]@{
Organization = $org
Team = $_.name
TeamId = $_.id
}
}
}
$teams


$Teams | Where-Object { $_.Name -like 'Team*' } | ForEach-Object {
Remove-GitHubTeam -Organization $_.Organization -Name $_.Name -Verbose
}
Loading