@@ -50,6 +50,21 @@ type DefaultWorkflowPermissionOrganization struct {
50
50
CanApprovePullRequestReviews * bool `json:"can_approve_pull_request_reviews,omitempty"`
51
51
}
52
52
53
+ // SelfHostedRunnersSettingsOrganization represents the self-hosted runners permissions settings for repositories in an organization.
54
+ type SelfHostedRunnersSettingsOrganization struct {
55
+ EnabledRepositories * string `json:"enabled_repositories,omitempty"`
56
+ SelectedRepositoriesURL * string `json:"selected_repositories_url,omitempty"`
57
+ }
58
+
59
+ func (s SelfHostedRunnersSettingsOrganization ) String () string {
60
+ return Stringify (s )
61
+ }
62
+
63
+ // SelfHostedRunnersSettingsOrganizationOpt specifies the self-hosted runners permissions settings for repositories in an organization.
64
+ type SelfHostedRunnersSettingsOrganizationOpt struct {
65
+ EnabledRepositories * string `json:"enabled_repositories,omitempty"`
66
+ }
67
+
53
68
// GetActionsPermissions gets the GitHub Actions permissions policy for repositories and allowed actions in an organization.
54
69
//
55
70
// GitHub API docs: https://docs.github.com/rest/actions/permissions#get-github-actions-permissions-for-an-organization
@@ -306,3 +321,128 @@ func (s *ActionsService) EditArtifactAndLogRetentionPeriodInOrganization(ctx con
306
321
307
322
return s .client .Do (ctx , req , nil )
308
323
}
324
+
325
+ // GetSelfHostedRunnersSettingsInOrganization gets the self-hosted runners permissions settings for repositories in an organization.
326
+ //
327
+ // GitHub API docs: https://docs.github.com/rest/actions/permissions#get-self-hosted-runners-settings-for-an-organization
328
+ //
329
+ //meta:operation GET /orgs/{org}/actions/permissions/self-hosted-runners
330
+ func (s * ActionsService ) GetSelfHostedRunnersSettingsInOrganization (ctx context.Context , org string ) (* SelfHostedRunnersSettingsOrganization , * Response , error ) {
331
+ u := fmt .Sprintf ("orgs/%v/actions/permissions/self-hosted-runners" , org )
332
+
333
+ req , err := s .client .NewRequest ("GET" , u , nil )
334
+ if err != nil {
335
+ return nil , nil , err
336
+ }
337
+
338
+ settings := new (SelfHostedRunnersSettingsOrganization )
339
+ resp , err := s .client .Do (ctx , req , settings )
340
+ if err != nil {
341
+ return nil , resp , err
342
+ }
343
+
344
+ return settings , resp , nil
345
+ }
346
+
347
+ // EditSelfHostedRunnersSettingsInOrganization sets the self-hosted runners permissions settings for repositories in an organization.
348
+ //
349
+ // GitHub API docs: https://docs.github.com/rest/actions/permissions#set-self-hosted-runners-settings-for-an-organization
350
+ //
351
+ //meta:operation PUT /orgs/{org}/actions/permissions/self-hosted-runners
352
+ func (s * ActionsService ) EditSelfHostedRunnersSettingsInOrganization (ctx context.Context , org string , opt SelfHostedRunnersSettingsOrganizationOpt ) (* Response , error ) {
353
+ u := fmt .Sprintf ("orgs/%v/actions/permissions/self-hosted-runners" , org )
354
+
355
+ req , err := s .client .NewRequest ("PUT" , u , opt )
356
+ if err != nil {
357
+ return nil , err
358
+ }
359
+
360
+ return s .client .Do (ctx , req , nil )
361
+ }
362
+
363
+ // SelfHostedRunnersAllowedRepos represents the repositories that are allowed to use self-hosted runners in an organization.
364
+ type SelfHostedRunnersAllowedRepos struct {
365
+ TotalCount int `json:"total_count"`
366
+ Repositories []* Repository `json:"repositories"`
367
+ }
368
+
369
+ // ListRepositoriesSelfHostedRunnersAllowedInOrganization lists the repositories that are allowed to use self-hosted runners in an organization.
370
+ //
371
+ // GitHub API docs: https://docs.github.com/rest/actions/permissions#list-repositories-allowed-to-use-self-hosted-runners-in-an-organization
372
+ //
373
+ //meta:operation GET /orgs/{org}/actions/permissions/self-hosted-runners/repositories
374
+ func (s * ActionsService ) ListRepositoriesSelfHostedRunnersAllowedInOrganization (ctx context.Context , org string , opts * ListOptions ) (* SelfHostedRunnersAllowedRepos , * Response , error ) {
375
+ u := fmt .Sprintf ("orgs/%v/actions/permissions/self-hosted-runners/repositories" , org )
376
+ u , err := addOptions (u , opts )
377
+ if err != nil {
378
+ return nil , nil , err
379
+ }
380
+
381
+ req , err := s .client .NewRequest ("GET" , u , nil )
382
+ if err != nil {
383
+ return nil , nil , err
384
+ }
385
+
386
+ settings := new (SelfHostedRunnersAllowedRepos )
387
+ resp , err := s .client .Do (ctx , req , settings )
388
+ if err != nil {
389
+ return nil , resp , err
390
+ }
391
+
392
+ return settings , resp , nil
393
+ }
394
+
395
+ // SetRepositoriesSelfHostedRunnersAllowedInOrganization allows the list of repositories to use self-hosted runners in an organization.
396
+ //
397
+ // GitHub API docs: https://docs.github.com/rest/actions/permissions#set-repositories-allowed-to-use-self-hosted-runners-in-an-organization
398
+ //
399
+ //meta:operation PUT /orgs/{org}/actions/permissions/self-hosted-runners/repositories
400
+ func (s * ActionsService ) SetRepositoriesSelfHostedRunnersAllowedInOrganization (ctx context.Context , org string , repositoryIDs []int64 ) (* Response , error ) {
401
+ u := fmt .Sprintf ("orgs/%v/actions/permissions/self-hosted-runners/repositories" , org )
402
+
403
+ req , err := s .client .NewRequest ("PUT" , u , struct {
404
+ IDs []int64 `json:"selected_repository_ids"`
405
+ }{IDs : repositoryIDs })
406
+ if err != nil {
407
+ return nil , err
408
+ }
409
+
410
+ return s .client .Do (ctx , req , nil )
411
+ }
412
+
413
+ // AddRepositorySelfHostedRunnersAllowedInOrganization adds a repository to the list of repositories that are allowed to use self-hosted runners in an organization.
414
+ //
415
+ // GitHub API docs: https://docs.github.com/rest/actions/permissions#add-a-repository-to-the-list-of-repositories-allowed-to-use-self-hosted-runners-in-an-organization
416
+ //
417
+ //meta:operation PUT /orgs/{org}/actions/permissions/self-hosted-runners/repositories/{repository_id}
418
+ func (s * ActionsService ) AddRepositorySelfHostedRunnersAllowedInOrganization (ctx context.Context , org string , repositoryID int64 ) (* Response , error ) {
419
+ u := fmt .Sprintf ("orgs/%v/actions/permissions/self-hosted-runners/repositories/%v" , org , repositoryID )
420
+
421
+ req , err := s .client .NewRequest ("PUT" , u , nil )
422
+ if err != nil {
423
+ return nil , err
424
+ }
425
+
426
+ return s .client .Do (ctx , req , nil )
427
+ }
428
+
429
+ // RemoveRepositorySelfHostedRunnersAllowedInOrganization removes a repository from the list of repositories that are allowed to use self-hosted runners in an organization.
430
+ //
431
+ // GitHub API docs: https://docs.github.com/rest/actions/permissions#remove-a-repository-from-the-list-of-repositories-allowed-to-use-self-hosted-runners-in-an-organization
432
+ //
433
+ //meta:operation DELETE /orgs/{org}/actions/permissions/self-hosted-runners/repositories/{repository_id}
434
+ func (s * ActionsService ) RemoveRepositorySelfHostedRunnersAllowedInOrganization (ctx context.Context , org string , repositoryID int64 ) (* Response , error ) {
435
+ u := fmt .Sprintf ("orgs/%v/actions/permissions/self-hosted-runners/repositories/%v" , org , repositoryID )
436
+
437
+ req , err := s .client .NewRequest ("DELETE" , u , nil )
438
+ if err != nil {
439
+ return nil , err
440
+ }
441
+
442
+ resp , err := s .client .Do (ctx , req , nil )
443
+ if err != nil {
444
+ return resp , err
445
+ }
446
+
447
+ return resp , nil
448
+ }
0 commit comments