Repository: google/go-github (go)

Issue:
We do not set allows_public_repositories for actions runner groups
We currently cannot set the `allows_public_repositories` variable wich is an entity of a runner group and controls weither public repos can use that group. If it is set to false, public repos, even if they are specifically in the selected repos list, will not be able to use the runners from this group.

The docs on this are:
https://docs.github.com/en/rest/reference/actions#create-a-self-hosted-runner-group-for-an-organization

However there is a documentation bug since we tried it out and one can actually pass this value to api in the request body and not only gets it as response. It will be set properly. This is not how it is documented in GitHub API Docs. Thus we raised an issue to change docs on this since we guess it is intended to be used in request body and just not properly documented.
https://github.com/github/docs/issues/8209

However we still miss the implementation in go-github. 
So currently all Runner Groups created with this lib are  just for private repo since this flag is defaulted to false.

Pull request:
Add allows_public_repositories to actions_runner_group
Adds allows_public_repositories to request bodies of the
CreateRunnerGroup as well as UpdateRunnerGroup methods for github
actions.

This allows us to set the allows_public_repositories flag even if it is
not yet properly documented see https://github.com/github/docs/issues/8209
That flag controls if public repos can use runners of this group.
If it is disabled(default) even public repos that are added to the
selected_repositories list cannot use runners of this group.

With this change we can now set this properly and thus use runner groups
created by go-github also for public repos.

Fixes #1996

Patch:
diff --git a/github/actions_runner_groups.go b/github/actions_runner_groups.go
index 5772daaa..e34495a9 100644
--- a/github/actions_runner_groups.go
+++ b/github/actions_runner_groups.go
@@ -36,12 +36,15 @@ type CreateRunnerGroupRequest struct {
 	SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"`
 	// Runners represent a list of runner IDs to add to the runner group.
 	Runners []int64 `json:"runners,omitempty"`
+	// If set to True, public repos can use this runner group
+	AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
 }
 
 // UpdateRunnerGroupRequest represents a request to update a Runner group for an organization.
 type UpdateRunnerGroupRequest struct {
-	Name       *string `json:"name,omitempty"`
-	Visibility *string `json:"visibility,omitempty"`
+	Name                     *string `json:"name,omitempty"`
+	Visibility               *string `json:"visibility,omitempty"`
+	AllowsPublicRepositories *bool   `json:"allows_public_repositories,omitempty"`
 }
 
 // SetRepoAccessRunnerGroupRequest represents a request to replace the list of repositories
diff --git a/github/github-accessors.go b/github/github-accessors.go
index fb3e2903..3dcb9a4e 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -2916,6 +2916,14 @@ func (c *CreateOrgInvitationOptions) GetRole() string {
 	return *c.Role
 }
 
+// GetAllowsPublicRepositories returns the AllowsPublicRepositories field if it's non-nil, zero value otherwise.
+func (c *CreateRunnerGroupRequest) GetAllowsPublicRepositories() bool {
+	if c == nil || c.AllowsPublicRepositories == nil {
+		return false
+	}
+	return *c.AllowsPublicRepositories
+}
+
 // GetName returns the Name field if it's non-nil, zero value otherwise.
 func (c *CreateRunnerGroupRequest) GetName() string {
 	if c == nil || c.Name == nil {
@@ -15924,6 +15932,14 @@ func (u *UpdateCheckRunOptions) GetStatus() string {
 	return *u.Status
 }
 
+// GetAllowsPublicRepositories returns the AllowsPublicRepositories field if it's non-nil, zero value otherwise.
+func (u *UpdateRunnerGroupRequest) GetAllowsPublicRepositories() bool {
+	if u == nil || u.AllowsPublicRepositories == nil {
+		return false
+	}
+	return *u.AllowsPublicRepositories
+}
+
 // GetName returns the Name field if it's non-nil, zero value otherwise.
 func (u *UpdateRunnerGroupRequest) GetName() string {
 	if u == nil || u.Name == nil {


Test patch:
diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go
index 27489ad9..55de0b93 100644
--- a/github/actions_runner_groups_test.go
+++ b/github/actions_runner_groups_test.go
@@ -139,8 +139,9 @@ func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) {
 
 	ctx := context.Background()
 	req := CreateRunnerGroupRequest{
-		Name:       String("octo-runner-group"),
-		Visibility: String("selected"),
+		Name:                     String("octo-runner-group"),
+		Visibility:               String("selected"),
+		AllowsPublicRepositories: Bool(true),
 	}
 	group, _, err := client.Actions.CreateOrganizationRunnerGroup(ctx, "o", req)
 	if err != nil {
@@ -188,8 +189,9 @@ func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) {
 
 	ctx := context.Background()
 	req := UpdateRunnerGroupRequest{
-		Name:       String("octo-runner-group"),
-		Visibility: String("selected"),
+		Name:                     String("octo-runner-group"),
+		Visibility:               String("selected"),
+		AllowsPublicRepositories: Bool(true),
 	}
 	group, _, err := client.Actions.UpdateOrganizationRunnerGroup(ctx, "o", 2, req)
 	if err != nil {
@@ -541,17 +543,19 @@ func TestCreateRunnerGroupRequest_Marshal(t *testing.T) {
 	testJSONMarshal(t, &CreateRunnerGroupRequest{}, "{}")
 
 	u := &CreateRunnerGroupRequest{
-		Name:                  String("n"),
-		Visibility:            String("v"),
-		SelectedRepositoryIDs: []int64{1},
-		Runners:               []int64{1},
+		Name:                     String("n"),
+		Visibility:               String("v"),
+		SelectedRepositoryIDs:    []int64{1},
+		Runners:                  []int64{1},
+		AllowsPublicRepositories: Bool(true),
 	}
 
 	want := `{
 		"name": "n",
 		"visibility": "v",
 		"selected_repository_ids": [1],
-		"runners": [1]
+		"runners": [1],
+		"allows_public_repositories": true
 	}`
 
 	testJSONMarshal(t, u, want)
@@ -561,13 +565,15 @@ func TestUpdateRunnerGroupRequest_Marshal(t *testing.T) {
 	testJSONMarshal(t, &UpdateRunnerGroupRequest{}, "{}")
 
 	u := &UpdateRunnerGroupRequest{
-		Name:       String("n"),
-		Visibility: String("v"),
+		Name:                     String("n"),
+		Visibility:               String("v"),
+		AllowsPublicRepositories: Bool(true),
 	}
 
 	want := `{
 		"name": "n",
-		"visibility": "v"
+		"visibility": "v",
+		"allows_public_repositories": true
 	}`
 
 	testJSONMarshal(t, u, want)
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 03fd08ea..e0be0614 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -3415,6 +3415,16 @@ func TestCreateOrgInvitationOptions_GetRole(tt *testing.T) {
 	c.GetRole()
 }
 
+func TestCreateRunnerGroupRequest_GetAllowsPublicRepositories(tt *testing.T) {
+	var zeroValue bool
+	c := &CreateRunnerGroupRequest{AllowsPublicRepositories: &zeroValue}
+	c.GetAllowsPublicRepositories()
+	c = &CreateRunnerGroupRequest{}
+	c.GetAllowsPublicRepositories()
+	c = nil
+	c.GetAllowsPublicRepositories()
+}
+
 func TestCreateRunnerGroupRequest_GetName(tt *testing.T) {
 	var zeroValue string
 	c := &CreateRunnerGroupRequest{Name: &zeroValue}
@@ -18619,6 +18629,16 @@ func TestUpdateCheckRunOptions_GetStatus(tt *testing.T) {
 	u.GetStatus()
 }
 
+func TestUpdateRunnerGroupRequest_GetAllowsPublicRepositories(tt *testing.T) {
+	var zeroValue bool
+	u := &UpdateRunnerGroupRequest{AllowsPublicRepositories: &zeroValue}
+	u.GetAllowsPublicRepositories()
+	u = &UpdateRunnerGroupRequest{}
+	u.GetAllowsPublicRepositories()
+	u = nil
+	u.GetAllowsPublicRepositories()
+}
+
 func TestUpdateRunnerGroupRequest_GetName(tt *testing.T) {
 	var zeroValue string
 	u := &UpdateRunnerGroupRequest{Name: &zeroValue}