Skip to content

Commit a093666

Browse files
Merge remote-tracking branch 'origin/main' into copilot/consolidate-test-setup-tasks
# Conflicts: # tests/Enterprise.Tests.ps1 # tests/TEMPLATE.ps1
2 parents bdac052 + 02cb87b commit a093666

40 files changed

Lines changed: 959 additions & 66 deletions

.github/linters/.codespellrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[codespell]
22
skip = ./.github/linters
3+
ignore-words-list = afterall

examples/Connecting.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ Connect-GitHub
77

88
# Log on to a specific instance of GitHub (enterprise)
99
Connect-GitHub -Host 'msx.ghe.com'
10-
Get-GitHubRepository -Context 'msx.ghe.com/MariusStorhaug' # Contexts are selectable/overrideable on any call
10+
Get-GitHubRepository -Context 'msx.ghe.com/MariusStorhaug' # Contexts are selectable/overridable on any call
1111

1212
# Connect to GitHub interactively using OAuth App and Device Flow.
1313
Connect-GitHub -Mode 'OAuthApp' -Scope 'gist read:org repo workflow'
1414

1515
# Connect to GitHub interactively using less desired PAT flow, supports both fine-grained and classic PATs
1616
Connect-GitHub -UseAccessToken
1717

18-
# Connect to GitHub programatically (GitHub App Installation Access Token or PAT)
18+
# Connect to GitHub programmatically (GitHub App Installation Access Token or PAT)
1919
Connect-GitHub -Token ***********
2020

21-
# Connect to GitHub programatically (GitHub Actions)
21+
# Connect to GitHub programmatically (GitHub Actions)
2222
Connect-GitHub # Looks for the GITHUB_TOKEN variable
2323

2424
# Connect using a GitHub App and its private key (local signing of JWT)

src/classes/public/GitHubPermission.ps1

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@
9898
'Fine-grained',
9999
'Repository'
100100
),
101+
[GitHubPermission]::new(
102+
'artifact_metadata',
103+
'Artifact metadata',
104+
'View and manage artifact metadata.',
105+
'https://docs.github.com/rest/overview/permissions-required-for-github-apps' +
106+
'#repository-permissions-for-artifact-metadata',
107+
@(
108+
'read',
109+
'write'
110+
),
111+
'Fine-grained',
112+
'Repository'
113+
),
101114
[GitHubPermission]::new(
102115
'checks',
103116
'Checks',
@@ -569,6 +582,18 @@
569582
'Fine-grained',
570583
'Organization'
571584
),
585+
[GitHubPermission]::new(
586+
'custom_properties_for_organizations',
587+
'Custom properties for organizations',
588+
'View and manage custom properties for organizations.',
589+
'https://docs.github.com/rest/overview/permissions-required-for-github-apps',
590+
@(
591+
'read',
592+
'write'
593+
),
594+
'Fine-grained',
595+
'Organization'
596+
),
572597
[GitHubPermission]::new(
573598
'organization_custom_roles',
574599
'Custom repository roles',
@@ -607,6 +632,30 @@
607632
'Fine-grained',
608633
'Organization'
609634
),
635+
[GitHubPermission]::new(
636+
'organization_copilot_metrics',
637+
'Organization Copilot metrics',
638+
'View Copilot metrics for an organization.',
639+
'https://docs.github.com/rest/overview/permissions-required-for-github-apps' +
640+
'#organization-permissions-for-organization-copilot-metrics',
641+
@(
642+
'read'
643+
),
644+
'Fine-grained',
645+
'Organization'
646+
),
647+
[GitHubPermission]::new(
648+
'organization_credentials',
649+
'Organization credentials',
650+
'View and manage organization credentials.',
651+
'https://docs.github.com/rest/overview/permissions-required-for-github-apps',
652+
@(
653+
'read',
654+
'write'
655+
),
656+
'Fine-grained',
657+
'Organization'
658+
),
610659
[GitHubPermission]::new(
611660
'issue_fields',
612661
'Issue Fields',
@@ -762,6 +811,18 @@
762811
'Fine-grained',
763812
'Organization'
764813
),
814+
[GitHubPermission]::new(
815+
'organization_dependabot_dismissal_requests',
816+
'Organization Dependabot dismissal requests',
817+
'Review and manage Dependabot dismissal requests for an organization.',
818+
'https://docs.github.com/rest/overview/permissions-required-for-github-apps',
819+
@(
820+
'read',
821+
'write'
822+
),
823+
'Fine-grained',
824+
'Organization'
825+
),
765826
[GitHubPermission]::new(
766827
'organization_code_scanning_dismissal_requests',
767828
'Organization dismissal requests for code scanning',
@@ -788,6 +849,19 @@
788849
'Fine-grained',
789850
'Organization'
790851
),
852+
[GitHubPermission]::new(
853+
'organization_runner_custom_images',
854+
'Hosted runner custom images',
855+
'View and manage hosted runner custom images for an organization.',
856+
'https://docs.github.com/rest/overview/permissions-required-for-github-apps' +
857+
'#organization-permissions-for-hosted-runner-custom-images',
858+
@(
859+
'read',
860+
'write'
861+
),
862+
'Fine-grained',
863+
'Organization'
864+
),
791865
[GitHubPermission]::new(
792866
'organization_personal_access_token_requests',
793867
'Personal access token requests',
@@ -1157,6 +1231,18 @@
11571231
# ------------------------------
11581232
# Enterprise Fine-Grained Permission Definitions
11591233
# ------------------------------
1234+
[GitHubPermission]::new(
1235+
'enterprise_ai_controls',
1236+
'Enterprise AI controls',
1237+
'View and manage AI controls for an enterprise.',
1238+
'https://docs.github.com/enterprise-cloud@latest/rest/overview/permissions-required-for-github-apps',
1239+
@(
1240+
'read',
1241+
'write'
1242+
),
1243+
'Fine-grained',
1244+
'Enterprise'
1245+
),
11601246
[GitHubPermission]::new(
11611247
'enterprise_custom_properties',
11621248
'Custom properties',
@@ -1170,6 +1256,30 @@
11701256
'Fine-grained',
11711257
'Enterprise'
11721258
),
1259+
[GitHubPermission]::new(
1260+
'enterprise_copilot_metrics',
1261+
'Enterprise Copilot metrics',
1262+
'View Copilot metrics for an enterprise.',
1263+
'https://docs.github.com/enterprise-cloud@latest/rest/overview/permissions-required-for-github-apps' +
1264+
'#enterprise-permissions-for-enterprise-copilot-metrics',
1265+
@(
1266+
'read'
1267+
),
1268+
'Fine-grained',
1269+
'Enterprise'
1270+
),
1271+
[GitHubPermission]::new(
1272+
'enterprise_credentials',
1273+
'Enterprise credentials',
1274+
'View and manage enterprise credentials.',
1275+
'https://docs.github.com/enterprise-cloud@latest/rest/overview/permissions-required-for-github-apps',
1276+
@(
1277+
'read',
1278+
'write'
1279+
),
1280+
'Fine-grained',
1281+
'Enterprise'
1282+
),
11731283
[GitHubPermission]::new(
11741284
'enterprise_scim',
11751285
'Enterprise SCIM',
@@ -1196,6 +1306,30 @@
11961306
'Fine-grained',
11971307
'Enterprise'
11981308
),
1309+
[GitHubPermission]::new(
1310+
'enterprise_custom_enterprise_roles',
1311+
'Enterprise custom enterprise roles',
1312+
'Create, edit, delete and list custom enterprise roles.',
1313+
'https://docs.github.com/enterprise-cloud@latest/rest/overview/permissions-required-for-github-apps',
1314+
@(
1315+
'read',
1316+
'write'
1317+
),
1318+
'Fine-grained',
1319+
'Enterprise'
1320+
),
1321+
[GitHubPermission]::new(
1322+
'enterprise_custom_properties_for_organizations',
1323+
'Enterprise custom properties for organizations',
1324+
'View and manage custom properties for organizations at the enterprise level.',
1325+
'https://docs.github.com/enterprise-cloud@latest/rest/overview/permissions-required-for-github-apps',
1326+
@(
1327+
'read',
1328+
'write'
1329+
),
1330+
'Fine-grained',
1331+
'Enterprise'
1332+
),
11991333
[GitHubPermission]::new(
12001334
'enterprise_organization_installation_repositories',
12011335
'Enterprise organization installation repositories',
@@ -1259,6 +1393,19 @@
12591393
),
12601394
'Fine-grained',
12611395
'Enterprise'
1396+
),
1397+
[GitHubPermission]::new(
1398+
'enterprise_teams',
1399+
'Enterprise teams',
1400+
'View and manage enterprise teams.',
1401+
'https://docs.github.com/enterprise-cloud@latest/rest/overview/permissions-required-for-github-apps' +
1402+
'#enterprise-permissions-for-enterprise-teams',
1403+
@(
1404+
'read',
1405+
'write'
1406+
),
1407+
'Fine-grained',
1408+
'Enterprise'
12621409
)
12631410
)
12641411
}

src/classes/public/Releases/GitHubRelease.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Example: "## What's Changed\n### Other Changes\n* Fix: Enhance repository deletion feedback and fix typo..."
1818
[string] $Notes
1919

20-
# Specifies the commitish value that determines where the Git tag is created from
20+
# Specifies the committish value that determines where the Git tag is created from
2121
# Example: "main"
2222
[string] $Target
2323

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class GitHubCustomProperty {
2+
# The name of the custom property.
3+
[string] $Name
4+
5+
# The value of the custom property.
6+
[string] $Value
7+
8+
GitHubCustomProperty() {}
9+
10+
GitHubCustomProperty([PSCustomObject] $Object) {
11+
$this.Name = $Object.property_name ?? $Object.propertyName ?? $Object.Name
12+
$this.Value = $Object.value ?? $Object.Value
13+
}
14+
15+
[string] ToString() {
16+
return $this.Name
17+
}
18+
}

src/classes/public/Repositories/GitHubRepository.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
[GithubRepository] $ForkRepository
183183

184184
# Custom properties for the repository.
185-
[PSCustomObject] $CustomProperties
185+
[GitHubCustomProperty[]] $CustomProperties
186186

187187
# The clone URL of the repository.
188188
# Example: git://github.com/octocat/Hello-World.git
@@ -242,7 +242,7 @@
242242
MergeCommitMessage = 'mergeCommitMessage'
243243
TemplateRepository = 'templateRepository { id databaseId name owner { login } }'
244244
ForkRepository = 'parent { id databaseId name owner { login } }'
245-
CustomProperties = ''
245+
CustomProperties = 'repositoryCustomPropertyValues(first: 100) { nodes { propertyName value } }'
246246
CloneUrl = 'url'
247247
SshUrl = 'sshUrl'
248248
GitUrl = 'url'
@@ -298,7 +298,9 @@
298298
$this.SquashMergeCommitTitle = $Object.squash_merge_commit_title
299299
$this.MergeCommitMessage = $Object.merge_commit_message
300300
$this.MergeCommitTitle = $Object.merge_commit_title
301-
$this.CustomProperties = $Object.custom_properties
301+
$this.CustomProperties = $Object.custom_properties | ForEach-Object {
302+
[GitHubCustomProperty]::new($_)
303+
}
302304
$this.TemplateRepository = $null -ne $Object.template_repository ? [GitHubRepository]::New($Object.template_repository) : $null
303305
$this.ForkRepository = $null -ne $Object.parent ? [GitHubRepository]::New($Object.parent) : $null
304306
$this.CloneUrl = $Object.clone_url
@@ -353,6 +355,11 @@
353355
$this.SquashMergeCommitMessage = $Object.squashMergeCommitMessage
354356
$this.MergeCommitTitle = $Object.mergeCommitTitle
355357
$this.MergeCommitMessage = $Object.mergeCommitMessage
358+
if ($null -ne $Object.repositoryCustomPropertyValues -and $null -ne $Object.repositoryCustomPropertyValues.nodes) {
359+
$this.CustomProperties = $Object.repositoryCustomPropertyValues.nodes | ForEach-Object {
360+
[GitHubCustomProperty]::new($_)
361+
}
362+
}
356363
$this.TemplateRepository = $null -ne $Object.templateRepository ? [GitHubRepository]::New($Object.templateRepository) : $null
357364
$this.ForkRepository = $null -ne $Object.parent ? [GitHubRepository]::New($Object.parent) : $null
358365
$this.CloneUrl = -not [string]::IsNullOrEmpty($Object.url) ? $Object.url + '.git' : $null
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function Get-GitHubOidcSubjectClaimForOrganization {
2+
<#
3+
.SYNOPSIS
4+
Get the customization template for an OIDC subject claim for an organization
5+
6+
.DESCRIPTION
7+
Gets the customization template for an OpenID Connect (OIDC) subject claim for an organization.
8+
9+
.EXAMPLE
10+
```powershell
11+
Get-GitHubOidcSubjectClaimForOrganization -Organization 'PSModule' -Context $GitHubContext
12+
```
13+
14+
Gets the OIDC subject claim customization template for the 'PSModule' organization.
15+
16+
.NOTES
17+
[Get the customization template for an OIDC subject claim for an organization]
18+
(https://docs.github.com/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-an-organization)
19+
#>
20+
[OutputType([pscustomobject])]
21+
[CmdletBinding()]
22+
param(
23+
# The organization name. The name is not case sensitive.
24+
[Parameter(Mandatory)]
25+
[string] $Organization,
26+
27+
# The context to run the command in. Used to get the details for the API call.
28+
# Can be either a string or a GitHubContext object.
29+
[Parameter(Mandatory)]
30+
[object] $Context
31+
)
32+
33+
begin {
34+
$stackPath = Get-PSCallStackPath
35+
Write-Debug "[$stackPath] - Start"
36+
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
37+
# Required permissions: Administration org (read) or read:org
38+
}
39+
40+
process {
41+
$apiParams = @{
42+
Method = 'GET'
43+
APIEndpoint = "/orgs/$Organization/actions/oidc/customization/sub"
44+
Context = $Context
45+
}
46+
47+
Invoke-GitHubAPI @apiParams | ForEach-Object {
48+
Write-Output $_.Response
49+
}
50+
}
51+
52+
end {
53+
Write-Debug "[$stackPath] - End"
54+
}
55+
}

0 commit comments

Comments
 (0)